写了个修改信息的页面:
但是每次点玩修改后,值都没改变。经过调试发现,每次从TextBox得到的值都是原先的。最后定位到Page_Load()函数发现,每次触发Button_Click事件,都会从Page_Load()函数执行,于是把我修改在TextBox里的值重新刷新成原来的值了。
原先的代码:
protected void Page_Load(object sender, EventArgs e)
{
LoadInfo();
}
修改后的代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadInfo();
}
}
这样可以正常执行结果了。