多个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,如需转载请自行联系原作者

目录
打赏
0
0
0
0
46
分享
相关文章
sign check fail:check Sign and Data Fail报错攻略
错误码: com.alipay.api.AlipayApiException: sign check fail: check Sign and ​Fail            报错原因:验签失败 ,未使用正确的支付宝公钥     在新版接口的调用过程中,常常出现此报错。
4992 12
|
4月前
|
SQL
CHECK
【11月更文挑战第15天】
81 5
|
6月前
|
出现“Host key verification failed”错误--解决
遇到“Host key verification failed”错误,通常是因为远程主机密钥发生变化,与本地保存的信息不符。这种情况可能是远程主机系统更改或重装等原因导致的。解决方法是根据提示使用`ssh-keygen -f "/root/.ssh/known_hosts" -R "[10.61.0.152]:29022"`命令移除旧的密钥信息,然后重新尝试连接。
1148 5
译|Don’t just check errors, handle them gracefully(二)
译|Don’t just check errors, handle them gracefully(二)
135 0
译|Don’t just check errors, handle them gracefully(一)
译|Don’t just check errors, handle them gracefully
97 0
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.
2571 0
[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
1617 0
[Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode 解决方法