超市蜂蜜哪个牌子好:asp.net 复选框值的问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 16:01:10
在asp.netk中,DataGrid1中绑定了一个模板列里放的是复选框,问怎么能获得这些复选框的值?

一般是DataGrid触发的一个时间去捕获

比如DataGrid1_ItemCommand事件

e.Item.FindControl("复选框控件名") 用这个方法去捕获这个控件。

如果是VB.Net 就用Ctype(e.Item.FindControl("复选框控件名"),CheckBox).Checked
如果是C#就用(CheckBox)e.Item.FindControl("复选框控件名").Checked;

注意在onload裏面判断IsPostBack,否则的话DataGrid重新绑定,那个事件不会触发的。

DataGridCell c = new DataGridCell(行, 列);
c.Value