这是我以编程方式添加复选框的代码,但它不允许我添加事件 onchecked
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
CheckBox chk = new CheckBox();
chk.EnableViewState = true;
chk.Enabled = true;
chk.ID = "chkb";
DataRowView dr = (DataRowView)e.Row.DataItem;
e.Row.Cells[0].Controls.Add(chk);
e.Row.TableSection = TableRowSection.TableBody;
}
当我尝试添加这个时:
chk.CheckedChanged += checkBox_CheckedChanged;
I get this error :
"The name 'checkBox_CheckedChanged' does not exist in the current context",
即使我已经添加了这个功能:
private void CheckBox_CheckedChanged(object sender, System.EventArgs e)
{
Response.Write("in check changed object");
}