Funny Behaviour -- Probably Easily Answered

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

I am trying to gather data from various textboxes in a webform. Upon
loading, the form populates itself with values from a database. When the
Update button is pressed, the new values are loaded into an array and passed
to the data object.

The strange part is that when I pull the newly edited values from the
textboxes, the original values stick around. For example, I can change a
products name from "Fish Bait" to "Cat Food"... when I hit update, the value
will revert back to "Fish Bait".

I don't really know what the deal is, any suggestions?
 
Ahh, I knew it had to be something with the postback.

Thanks a lot, I appreciate your help

Ron
 
I am guessing something about your code that might or might not be correct.

page_load
{
//populate text boxes from data base
}

update_click()
{
//put the new values into the database.
}

If this is the case, then when you click the update button, page_load runs
FIRST so they old values would be put into the textboxes from the database.

now when the update happens, the values might be the original values, since
you assigned them.

try putting your //populate textboxes from data base int

page_load
{
if ( !Page.IsPostBack )
{
//populate textboxes from data base.
}
}

This should fix all your problems, if it doesn't let me know.

HTH,

bill
 
Back
Top