zoukankan
html css js c++ java
获取CheckBox在GridView模板列中的值
aspx:
<
asp:GridView
ID
="gvdeptusers"
runat
="server"
DataKeyNames
="id"
AutoGenerateColumns
="False"
Width
="100%"
ShowHeader
="False"
OnRowDataBound
="gvdeptusers_RowDataBound"
>
<
Columns
>
<
asp:BoundField
DataField
="names"
>
<
ItemStyle
Width
="8%"
HorizontalAlign
="Center"
/>
</
asp:BoundField
>
<
asp:BoundField
DataField
="deptname"
>
<
ItemStyle
Width
="10%"
HorizontalAlign
="Center"
/>
</
asp:BoundField
>
<
asp:TemplateField
>
<
ItemTemplate
>
<
asp:HiddenField
ID
="hdtype"
runat
="server"
Value
='<%#
Eval("user_classid") %
>
' />
<
asp:CheckBox
ID
="cbusers"
Text
='<%#
Eval("username") %
>
' runat="server" />
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
cs:
string
idStr
=
""
;
foreach
(GridViewRow row
in
this
.gvdeptusers.Rows)
{
if
(((CheckBox)row.FindControl(
"
cbusers
"
)).Checked
==
true
)
{
idStr
+=
this
.gvdeptusers.DataKeys[row.RowIndex].Value
+
"
<br>
"
;
}
}
Response.Write(idStr);
Response.End();
绑定选定值:
protected
void
gvdeptusers_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
int
strid
=
e.Row.RowIndex;
CheckBox cbusers
=
(CheckBox)e.Row.FindControl(
"
cbusers
"
);
if
(cbusers
!=
null
)
{
string
strhdtype
=
((HiddenField)e.Row.FindControl(
"
hdtype
"
)).Value;
if
(strhdtype
!=
"
1
"
&&
strhdtype
!=
"
8
"
) cbusers.Checked
=
true
;
}
}
很简单的代码,怕忘记所以记录于此。
查看全文
相关阅读:
淘宝返回顶部
混合布局
css布局使用定位和margin
选项卡 js操作
ul li 好友列表
js添加删除元素
下拉列表的简单操作
python笔记
kali linux 虚拟机网卡未启动
python 重新安装pip(python2和python3共存以及pip共存)
原文地址:https://www.cnblogs.com/cnaspnet/p/725425.html
最新文章
VMware下,windows7无法自动更新,故障80072EE2
Win7无法连接wifi网络的解决方法
开源框架 epics,开源画面编辑软件 edm
s7nodave用于上位机连接西门子PLC,开源项目epics
S7-1500 读取V90/S120/S210/G120的常用驱动参数
simotion读写CF卡,保存/读取变量
西门子 S7-1500 PLC,使用手轮控制伺服电机
循环
关于HTML和CSS
路径选择工具和形状工具
热门文章
PS入门
SQL操作
复杂网络社区发现方法
MySQL_PHP学习笔记_2015.04.19_PHP连接数据库
matlab笔记
linux笔记_20150417_ubuntu 常见问题_文件_音乐播放器
乌班图安装五笔输入法和搜狗输入法
单独删除std::vector <std::vector<string> > 的所有元素
jq时间五级联动,并且赋值input[格式可以修改]
小小计算器
Copyright © 2011-2022 走看看