runxinzhi.com
首页
百度搜索
获取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
;
}
}
很简单的代码,怕忘记所以记录于此。
相关阅读:
js的原型链
setTimeout浅析
并行模式库PPL应用实战(一):使用task类创建并行任务
PC客户端开发细节记录:保存GUID到VARIANT
UWP开发细节记录:DirectX::XMMATRIX 的坑
UWP开发细节记录:WRL::ComPtr 的坑
UWP开发细节记录:IStream 和 IRandomAccessStream^ 以及 IMFByteStream 互转
UWP开发细节记录:判断文件类型
UWP开发细节记录:加载图像文件到D2D位图和D3D纹理
基于纤程(Fiber)实现C++异步编程库(一):原理及示例
原文地址:https://www.cnblogs.com/cnaspnet/p/725425.html
最新文章
PHP环境搭建(Windows8.1+IIS8.5+PHP5.6+PHPStorm)
MVC中Filter拦截问题记录之重定向陷阱
C#多线程学习笔记
学习笔记--C#特性Attribute(一)
学习笔记--DI(依赖注入) 、Ioc(控制反转)
GZip、deflate和sdch压缩(网摘整理)
json+flexgrid+jbox组合运用页面刷新<jsp>
js url传值中文乱码之解决之道
java.sql.SQLException:ORA=00911:无效字符
ActiveMQ教程
热门文章
文件同步系统 DRBD
队列memcacheq 服务安装与原理
Ubuntu 建立 apache+php+mysql
谈谈js中for in 需要注意的地方
对jQuery.isArray方法的分析
对jQuery.extend()方法的分析
分析jQuery中的each方法
浏览器对新窗口打开页面的阻止情况
用css制作三角形
较复杂js的书写格式
Copyright © 2020-2023
润新知