How do I get Textbox contents in "code behind" to reflect current "on screen" contents
Posted on 2008-02-10
I am working on a web app using AJAX and the problem is:
Page uses an AJAX control toolkit tabcontainer with two tabs
Tab1 contains a gridview with a list of records
Tab2 contains text boxes reflecting the field contents of the currently selected gridview record on Tab1
All works fine for reflecting the proper contents in the text boxes when the record in the gridview is changed (text boxes not bound... contents updated when the gridview changes using code behind). For example in the code behind in the index changed event of the gridview, I have code like
Textbox1.Text = (appropriate gridview row/cell text)
This appears to work fine.
There is a webcontrols.button control to "Add" a new record. This button blanks the fields and positions on the textbox for entering new data, again, using code behind. For example, in the code behind in the click event of this button, I have code such as:
Textbox1.Text = ""
I have set a break point in this code and the textboxes reflect the "new blank values" appropriately.
There is a "Save" button for saving the new data.
When I use the click event of the save button to prepare a SQL query for inserting a new record, the textboxes reflect the original content before blanking instead of the "new" data I entered.
What am I missing about the behavior of AJAX and code behind.... It appears the textboxes contain the original information displayed when the form was first loaded, even though I have performed changes to them on the page.