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
;
}
}
很简单的代码,怕忘记所以记录于此。
查看全文
相关阅读:
RUNOOB.COM-python网络编程-(python3.5.0)
windows查看服务
计算机网络里的一些理解
如果面试有傻逼问道oracle怎么启动的
推荐一个学习数据库的地方
电脑中的驱动程序是什么,是干什么的
Raspberry Pi 4B 之 Python开发
Ubuntu20.04+EdgexFoundry边缘计算微服务搭建-----遇到的问题-----make build 被墙问题
Raspberry Pi 4B + Ubuntu 20.04 server for arm64 的wifi配置
关于PicoNeo开发环境的Unity3D+AndroidSDK配置
原文地址:https://www.cnblogs.com/cnaspnet/p/725425.html
最新文章
flash/flex builder在IE中stage.stageWidth始终为0的解决办法
“AS3.0高级动画编程”学习:第三章等角投影(上)
as3中的embed
as3:sprite作为容器使用时,最好不要指定width,height
1.第一个C#代码
Lombok的使用
typescript
flutter入门
webpack
面试题一
热门文章
面试题
浏览器性能指标
前端优化
全排列和优化
前端安全
javascript基础
python博客笔记(2.7.11)
廖雪峰-python3-基础教程--好基础没意思
RUNOOB.COM-Python2.x与3.x版本区别
RUNOOB.COM-python多线程-(python3.5.0)
Copyright © 2011-2022 走看看