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!

Old values retained from auto-populated form 1

Status
Not open for further replies.

fusionboy

Programmer
Jul 14, 2003
27
US
Hi Everyone,

I'm new to C# and I've got a strange bug that I can't figure out. I'm creating an EditInfo page, and I'm auto-populating the form with values from a database. I have a method that is triggered on submit that is supposed to retrieve the (edited) values from the form and update the database. The problem is that this method is not picking up any of the changes made to the textboxes. It's still seeing the Textbox.Text value from the auto-population.

Any ideas?

thanks!
 
Does your form rebind the data from the database before reading the values and trying to save them?

If this is ASP.NET you can use Page.IsPostback to determine wether the form is a postback and therefore only bind the data the first time it is displayed.
Code:
if(!Page.IsPostback) BindData();

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Thanks for your response, Rob! You were right -- the auto-populate method was being called on page load. What I've learned here is that:

Page_Load() is fired EVERY time the page is called -- INCLUDING a postback.

Of course, this makes sense now.

thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top