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

相关文章
|
19天前
|
网络安全
出现“Host key verification failed”错误--解决
遇到“Host key verification failed”错误,通常是因为远程主机密钥发生变化,与本地保存的信息不符。这种情况可能是远程主机系统更改或重装等原因导致的。解决方法是根据提示使用`ssh-keygen -f "/root/.ssh/known_hosts" -R "[10.61.0.152]:29022"`命令移除旧的密钥信息,然后重新尝试连接。
48 5
check sign Fail!或sign check fail: check Sign and Data Fail!-自查方案
一、报这个错大多都是支付宝公钥配置错误,不同环境的公钥是不同的,大家先确认自己的支付宝公钥获取是否正确:  1. 沙箱公钥【查看】 密钥生成可参照【如何生成RSA,RSA2密钥】  2. 开放平台密钥【查看】,已创建应用的,直接打开对应的应用进行查看, 创建应用可参照:【如何创建应用】 打开应用查...
1894 12
|
2月前
|
Linux 开发工具
You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofi
linux配置环境变量操作失误出现:/usr/libexec/grepconf.sh: line 5: grep: command not found 的解决办法
52 2
|
网络安全 开发工具
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
951 0
【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
configure: error: SELinux selected but libselinux not found
configure: error: SELinux selected but libselinux not found
102 0
gconf-sanity-check-2 exited with status 256
gconf-sanity-check-2 exited with status 256
|
安全
Error Code: 1175. You are using safe update mode and you tried to update a t
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/79677217 在安全模式下,只能根据主键来做修改,所以使用非主键修改,那么将要解除安全模式,然后再执行操作。
1634 0
|
关系型数据库 网络虚拟化