Funny Behaviour -- Probably Easily Answered

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?
 
R

Ron

Ahh, I knew it had to be something with the postback.

Thanks a lot, I appreciate your help

Ron
 
W

William F. Robertson, Jr.

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top