zoukankan
html css js c++ java
DataGrid中使用CheckBox的CheckedChanged事件
使用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)
{
if
(e.Item.ItemType
==
ListItemType.Item
||
e.Item.ItemType
==
ListItemType.AlternatingItem)
{
CheckBox chbIsActive
=
e.Item.FindControl(
"
chbIsActive
"
)
as
CheckBox;
chbIsActive.CheckedChanged
+=
new
EventHandler(chbIsActive_CheckedChanged);
}
}
3、编写事件代码
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();
}
查看全文
相关阅读:
[C#][控件]WebBrowser 使用范例
[java]经验集
[html][easyui]DataGrid 绑定
[转]jQuery 读取 xml
[转][html]大文件下载
[转][javascript]判断传入参数
[html][javascript] Cookie
[bat]批处理删默认共享和清理垃圾
[转]JavaScript RegExp 对象参考手册
5个编程问题(1小时解决)
原文地址:https://www.cnblogs.com/chenjunbiao/p/1760271.html
最新文章
假期(codevs 3622)
奶牛健美操(codevs 3279)
一次函数
矿场搭建(codevs 1996)
动态规划练习题
树形DP习题
模拟赛1103d1
模拟赛1102d2
模拟赛1102d1
模拟赛1101d2
热门文章
字符串中字符调换
二进制
高精度乘法
排序
进位
*并查集的题*
容器知识
逆元
匈牙利算法
KM算法
Copyright © 2011-2022 走看看