Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net changes not written to database?!? VS.Net 2003

Status
Not open for further replies.
Jan 23, 2002
63
US
I've got a form, which has a ton of fields. I am NOT using data binding. I programmatically create a data adapter and load the values into a table, then populate the fields on load.

When the user clicks save, I gather the data from the fields and generate an UPDATE command and use a SQLCommand to write it to the database.

The problem is, when the user trypes something into one of the fields and hits Save, the code reads the value (say, of a text box) and gets the ORIGINAL value of that field, rather than the UPDATED value that the user entered.

What is wrong here, and how can I fix it?

Thanks!
 
Not sure what language you use to do the code. But I think I had a similar problem with ASP.Net with VB. I initialized some controls on a form and if they were updated and a button clicked to post them to the server and onto a DB the code would only get the original initialized values.

I fixed my code, assuming that you do initialize your control values, by placeing all initialization in a Page_Init Sub instead or a Page_Load.

For some reason, on postback, the Page_Load would reinitialize the controls and prevent the updated values from being captured and sent back to the DB. Afterwards, the new values were caught.

Hope this help. If not then goodluck.
 
Okay, now I feel like an IDIOT. I knew about how page load works, and I knew to check for page.ispostback before initializing controls, but I DIDN'T DO IT!

Doh!!!

Thanks for giving me back my brain cell, LethalPacifier!


[2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top