Unbound fields not getting updated, written to DB VS.Net 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got an asp.net 1.0 web 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!
 
In your server page_load event, use If Not Page.IsPostBack and skip the
prepopulation.
 
DOH! My brain cell was on holiday. Sure enough, I wasn't checking for
IsPostBack in Page Load, so I was reinitializing the controls.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top