Clearing Variables

  • Thread starter Thread starter Tyros
  • Start date Start date
T

Tyros

I'm new to C# and I'm dynamically creating a table control that contains a
text control inside one of the cells. I load the values of each text field
with an SQL call. The form is simple and I'm getting HR information from the
DB. When the page loads the first time and looks up the customers
information based on his/her NT login ID everything works great. I want to
have the ability to change the NT login ID in the form and then repost the
page/information back to itself, lookup the NT login in the DB and then post
the new information in the form.

This is were I'm running into problems. When I change the NT login name, the
information is not being updated. When I tracing through the code in the
debugger, I can see the variables being updated with the new information
from the database, but the fields in my page don't update???? Has anyone
else seen this problem? Is there anything I can do to clear these fields
before I update them? I suspect the problem is due to the way C# maintains
sessions and session variables, but I'm not sure.
 
Hi,

Ensure you call the Page.DataBind() method upon postback. If you don't, the
controls will most likely restore their old values saved to the page's
viewstate.
 
Back
Top