TextBoxes don't use viewstate to maintain their values. Like many
"HTML-Like" controls the Web Forms Textbox controls simply POST their data
from the client to the server and then the server simply takes that value
and makes it become the default value of the control (using VALUE=) for the
trip from the server back to the client.
You can verify that TextBoxes don't use viewstate by enabling page tracing
and looking at the Control Tree section after doing a postback.
Anyway, you are probably better off just updating all the textbox values
rather than checking to see what has changed as checking to see what has
changed would take more resources than just updating the values.
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:57**********************************@microsof t.com...
Hi I know there are many posts on this but cant seem to find simple
answer.
I have lots of text boxes in a datalist edittemplate control. i dont want
to
do an update statement for all of them, as the user may only change one
value. I know you can use viewstate to check if value has changed between
last postback and what is currently in the Text property (can I?). So, is
this correct syntax (focusing on the viewstate line)??
foreach (Control control in e.Item.Controls)
{
if(control is TextBox)
{
currenttextboxvalue = ((TextBox) control).Text;
textboxid = control.ID;
if (ViewState[textboxid].ToString() != currenttextboxvalue) {
//then user has changed value therefore build an update statement
string then later build a sql command
}
}
}