我不知道为什么会这样,Page_Load()
事件仍然可以,但是我在Check Checked change事件中遇到了错误,下面是代码
我没有收到任何异常,但是当我打开浏览器控制台时,由于上面的错误ViewState数据未在回发中维护,并且在下面的代码row.BackColor = System.Drawing.Color.Empty;
中也无法正常工作,因此显示了以上错误
请告诉我为什么会这样
protected void chkGridRow_CheckedChanged(object sender, EventArgs e)
{
try
{
GridViewRow row = (GridViewRow)((CheckBox)sender).NamingContainer;
CheckBox chkGridRow = (CheckBox)row.Cells[0].FindControl("chkGridRow");
if (chkGridRow.Checked)
{
CopyGridRowsData(row);
row.BackColor = System.Drawing.Color.LightGreen;
}
else
{
using(DataTable dtSelectedTasks = (DataTable)ViewState["dtSelectedTasks"])
{
dtSelectedTasks.Rows.Remove(dtSelectedTasks.Rows.Find((row.Cells[1].FindControl("lblTaskId") as Label).Text));
ViewState["dtSelectedTasks"] = dtSelectedTasks;
}
row.BackColor = System.Drawing.Color.Empty;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}