G
Guest
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
}
}
}
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
}
}
}