您的位置:首页 > 其它

DataGrid中使用CheckBox的CheckedChanged事件

2005-09-07 13:52 316 查看
使用DataGrid的过程中常会用到CheckBox控件,并使用它的CheckedChanged事件。使用如下:

1、CheckBox控件需要设置AutoPostBack="true"

<asp:CheckBox id="chbIsActive" runat="server" AutoPostBack="true"></asp:CheckBox>

2、CheckBox控件的事件须在DataGrid的ItemCreated定义才能生效

private void grdStructure_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
private void chbIsActive_CheckedChanged(object sender, EventArgs e)
{
CheckBox chbIsActive = (CheckBox)sender;

Guid structureUID = new Guid(chbIsActive.Attributes["StructureUID"]);
bool isActive = chbIsActive.Checked;

IPMStructureManager manager = PMStructureManagerFactory.GetInstance();
manager.SetActive(structureUID, isActive);

this.Binding();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: