多个check处理

简介:

1种:
前台:<div class="overdiv">
<asp:Repeater runat="server" ID="rpt_hobby">
<HeaderTemplate><ol></HeaderTemplate>
<ItemTemplate>
<li><input type="checkbox" id="chkhobby" name="hobby" value='<%#Eval("id") %>'><%#Eval("val") %></li>
</ItemTemplate>
<FooterTemplate></ol> </FooterTemplate>
</asp:Repeater></div>
后台取值:
Request["hobby"]
2种:
前台: <div class="overdiv">
<asp:Repeater runat="server" ID="rpt_hobby">
<HeaderTemplate><ol></HeaderTemplate>
<ItemTemplate>
<li><input type="checkbox" id="chkhobby" runat="server" value='<%#Eval("id") %>'><%#Eval("val") %></li>
</ItemTemplate>
<FooterTemplate></ol> </FooterTemplate>
</asp:Repeater></div>

后台赋值:
string hobbystr = dv[0].Row["hobby"].ToString();
if (!string.IsNullOrEmpty(hobbystr))
{
string[] hb = hobbystr.Split(',');
for (int i = 0; i < hb.Length; i++)
{
foreach (RepeaterItem rptitem in this.rpt_hobby.Items)
{
HtmlInputCheckBox chkhobby = (HtmlInputCheckBox)rptitem.FindControl("chkhobby");
if (chkhobby != null && chkhobby.Value == hb[i])
{
chkhobby.Checked = true;
}
}
}
}
后台取值:
string hobby = "";
int currentnum = 0;
foreach (RepeaterItem rptitem in this.rpt_hobby.Items)
{
HtmlInputCheckBox chkhobby = (HtmlInputCheckBox)rptitem.FindControl("chkhobby");
if (chkhobby != null && chkhobby.Checked)
{
if (currentnum > 0)
hobby += ",";
hobby += chkhobby.Value;
currentnum++;
}

}



本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2009/08/05/1539227.html,如需转载请自行联系原作者

相关文章
|
1月前
|
SQL
CHECK
【11月更文挑战第15天】
41 5
|
3月前
|
网络安全
出现“Host key verification failed”错误--解决
遇到“Host key verification failed”错误,通常是因为远程主机密钥发生变化,与本地保存的信息不符。这种情况可能是远程主机系统更改或重装等原因导致的。解决方法是根据提示使用`ssh-keygen -f "/root/.ssh/known_hosts" -R "[10.61.0.152]:29022"`命令移除旧的密钥信息,然后重新尝试连接。
787 5
|
6月前
|
JSON 数据格式
【ERROR】Error: transaction invalidated with status (ENDORSEMENT_POLICY_FAILURE)
【ERROR】Error: transaction invalidated with status (ENDORSEMENT_POLICY_FAILURE)
52 0
|
7月前
|
Java
failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code
failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code
131 0
|
7月前
|
应用服务中间件 Python 容器
ERROR [ntContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer 1917: Failed to check/redeclare aut
ERROR [ntContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer 1917: Failed to check/redeclare aut
271 0
|
Linux
WARNING: Re-reading the partition table failed with error 22: Invalid argument
在划分磁盘分区时,遇到错误“WARNING: Re-reading the partition table failed with error 22: Invalid argument” 如下所示: [root@DB-Server u02]# fdisk -l   Disk /dev/sda: 500.
2547 0
|
C语言
[Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode 解决方法
[Error] ‘for’ loop initial declarations are only allowed in C99 or C11 mode [Note] use option -std=c99,-std=gnu99,-std=c11 or-std=gnu11 to compile your code
1533 0
[Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode 解决方法
|
C语言
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
903 0
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
|
安全
Error Code: 1175. You are using safe update mode and you tried to update a t
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/79677217 在安全模式下,只能根据主键来做修改,所以使用非主键修改,那么将要解除安全模式,然后再执行操作。
1656 0
|
关系型数据库 网络虚拟化