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
;
}
}
很简单的代码,怕忘记所以记录于此。
查看全文
相关阅读:
spring data jpa删除的使用方式
javax.persistence.TransactionRequiredException: No transactional EntityManager available
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result异常的解决方法
JS比较两个数组是否相等 是否拥有相同元素
HttpSession的线程安全问题及注意事项
easyui datagrid editor onBeforeEdit事件下使用getEditor和getEditors失效
JQuery easyUi datagrid 中 editor 动态设置最大值最小值
kaptcha验证码组件使用简介
ohasd failed to start: Inappropriate ioctl for device
web报表工具FineReport常见的数据集报错错误代码和解释
原文地址:https://www.cnblogs.com/cnaspnet/p/725425.html
最新文章
HDU 1695 GCD 容斥
poj 1845 Sumdiv 约数和定理
奇怪的数学公式系列
Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学
Codeforces Educational Codeforces Round 5 D. Longest k-Good Segment 尺取法
Codeforces Educational Codeforces Round 5 C. The Labyrinth 带权并查集
Codeforces Educational Codeforces Round 5 B. Dinner with Emma 暴力
Codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers 高精度比大小,模拟
hdu 4859 海岸线 最小割
《山桂~少女与少女等待秋日再会》
热门文章
hdu 4858 项目管理 分块
hdu 4857 逃生 拓扑排序
Codeforces Round #181 (Div. 2) C. Beautiful Numbers 排列组合 暴力
Codeforces Round #181 (Div. 2) B. Coach 带权并查集
Codeforces Round #181 (Div. 2) A. Array 构造
Codeforces Round #180 (Div. 2) D. Fish Weight 贪心
Codeforces Round #180 (Div. 2) C. Parity Game 数学
Codeforces Round #180 (Div. 2) B. Sail 贪心
Java实现主线程等待子线程
动态修改datagrid中的numberbox的最大值和最小值
Copyright © 2011-2022 走看看