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
;
}
}
很简单的代码,怕忘记所以记录于此。
查看全文
相关阅读:
Electron踩坑记录
TypeScript实现设计模式——生成器模式
在express中使用ES7装饰器构建路由
微信小程序下载文件(非图片),并校验扩展名。
防抖与节流
yarn
spark
docker php-fpm中安装GD库
thinkphp6 多应用路由遇坑记
CentOS 7 开启SSH远程登录
原文地址:https://www.cnblogs.com/cnaspnet/p/725425.html
最新文章
SQLSEVER结合WEBAPI执行定时任务
WEUI Select 组件增加搜索栏
layui 列表操作按钮过多自动隐藏后,按钮监听事件失效问题
HTTP状态码常见的网站错误代码大全
【转载】C#将字符串中字母全部转换为大写或者小写
web请求报出 “超过了最大请求长度”
Runnable和Thread的区别
Java集合
IDEA安装后的一些设置
JAVA通信系列一:Java Socket技术总结
热门文章
js生成UUID
Gradle添加依赖报红
HttpClient详细使用
Guice快速入门教程
解决mysql问题:由于找不到MSVCR120.dll,无法继续执行代码.重新安装程序可能会解决此问题。
ClickHouse亿点抽样展示
Asp.NETCore 部署IIS配置了允许跨域但还是不支持 PUT , POST请求
使用 webpack 手动搭建 vue 项目
使用Github Actions将Vue项目部署到Github Pages
关于HTTP
Copyright © 2011-2022 走看看