ASP.NET 1.1-我在ASPX页面上有一个DataGrid,该页面是数据绑定的,并在文本框中显示一个值。 用户可以更改此值,然后单击一个按钮,该按钮后面的代码基本上会遍历网格中的每个DataGridItem,对文本框ID进行FindControl,然后将.Text值分配给变量,该变量随后用于更新数据库。 DataGrid随新值反弹。
我遇到的问题是,在将.Text值分配给变量时,要检索的值是原始数据绑定值,而不是新输入的用户值。 关于什么可能导致这种行为的任何想法?
代码示例:
foreach(DataGridItem dgi in exGrid.Items)
{
TextBox Text1 = (TextBox)dgi.FindControl("TextID");
string exValue = Text1.Text; //This is retrieving the original bound value not the newly entered value
// do stuff with the new value
}