ckeckbox 编组问题 为什么不用<asp:checkboxlist控件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是啊!可以用checkboxlist:1、选项值保存到数据库 string SelectItem = "";//声明一个变量来接受选项 for (int i = 0; i < CheckBoxListID.Items.Count; i++) {//用for循环将所有选项用","隔开连接起来 if (CheckBoxListID.Items[i].Selected) { SelectItem = SelectItem + CheckBoxListID.Items[i].Value + ",";//选项后加","隔开 } } ht.Add("字段名",SelectItem.ToString());2、选项值由数据库绑定到CheckBoxList string SelectItem = dr["字段名"].ToString(); string[] arrStr = SelectItem.Split(',');//字段是以","隔开 foreach (string str in arrStr) { for (int i = 0; i <CheckBoxListID.Items.Count; i++) { if (this.CheckBoxListID.Items[i].Value == str) { this.CheckBoxListID.Items[i].Selected = true; } } } tangible T4 Editor plus modeling tools for VS2010 安装问题 VS中怎样自动生成文件夹 新手请教! 求救~asp.net指定列名查询 asp.net中如何制作无组件的本地文件选择框 页面显示饼形图的问题,请各位大侠,帮忙! 急!!把asp程序转换成java,请高手帮忙,谢谢!!!!!!!! 怎样才能不产生CS文件? 把CS文件里的内容放ASPX一起? 有关marquee标签onmouseover事件失效问题 asp.net简单问题 如何在c# .cs文件获取checkbox的name的值。 开发像阿里爸爸的网站,能遇到什么样的问题?
1、选项值保存到数据库
string SelectItem = "";//声明一个变量来接受选项
for (int i = 0; i < CheckBoxListID.Items.Count; i++)
{//用for循环将所有选项用","隔开连接起来
if (CheckBoxListID.Items[i].Selected)
{
SelectItem = SelectItem + CheckBoxListID.Items[i].Value + ",";//选项后加","隔开
}
}
ht.Add("字段名",SelectItem.ToString());2、选项值由数据库绑定到CheckBoxList
string SelectItem = dr["字段名"].ToString();
string[] arrStr = SelectItem.Split(',');//字段是以","隔开
foreach (string str in arrStr)
{
for (int i = 0; i <CheckBoxListID.Items.Count; i++)
{
if (this.CheckBoxListID.Items[i].Value == str)
{
this.CheckBoxListID.Items[i].Selected = true;
}
}
}