0
我在GridView中动态创建了CheckBox,但CheckedChanged事件在点击两次时触发。动态创建的CheckBoxs在第二次点击时触发,而不是第一次
哪里错了?
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
// check if it's not a header and footer
if (e.Row.RowType == DataControlRowType.Row)
{
CheckBox chk = new CheckBox();
chk.AutoPostBack = true;
// add checked changed event to checkboxes
chk.CheckedChanged += new EventHandler(chk_CheckedChanged);
e.Row.Cells[1].Controls.Add(chk); // add checkbox to second column
}
}
是否给Checked字段一个初始值会改变什么?即:chk.Checked = false; – lancew