asp:CheckBoxList
来源:互联网 发布:linux 线程私有变量 编辑:程序博客网 时间:2024/05/21 11:39
数据绑定:
SqlConnection con = new SqlConnection("server=.;database=diancai;uid=sa;pwd=;");
con.Open();
//7元荤菜
SqlCommand cmd1 = new SqlCommand("select * from CaiXinxi where caiShuxing='荤' and caiSpr=0 and (select count(*) from CaiXinxi where caiXingqi like '%" + LabelDay.Text + "%')>0", con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
CheckBoxList7hun.DataSource = ds1;
CheckBoxList7hun.DataTextField = "caiMingcheng";
CheckBoxList7hun.DataBind();
con.Close();
判断CheckBoxList被选中的数量:
int count2 = 0;
foreach (ListItem litem in CheckBoxListsu.Items)
{
if (litem.Selected)
{
count2 ++;
}
}
if (count2 != 2)
{
Response.Write("<script>alert(/"素菜要两份哦!!/");</script>");
return;
}
//选中的是哪两个菜
string m_strTemp = string.Empty;
for (int i = 0; i < CheckBoxListsu.Items.Count; i++)//读取CheckBoxList 选中的值,保存起来
{
if (CheckBoxListsu.Items[i].Selected)
{
m_strTemp += CheckBoxListsu.Items[i].Value + "','";
}
}
当有多个chackbox被选中,写入数据库时:
SqlCommand cmd1 = new SqlCommand("insert into Diancai (hun1,su1,su2,yinliao) values('" + CheckBoxList7hun.SelectedValue + "','" + m_strTemp + CheckBoxListyinliao.SelectedValue + "')", con);
cmd1.ExecuteNonQuery();
- asp:CheckBoxList
- ASP.NET CheckBoxList 组件
- asp.net CheckBoxList 控件
- <asp:CheckBoxList>的用法
- Csharp:asp.net CheckBoxList databind
- Csharp:asp.net CheckBoxList databind
- asp.net core 绑定CheckBoxList
- checkBoxList
- CheckBoxList
- CheckBoxList
- CheckBoxList
- ASP.NET中WebForm组件CheckBoxList编程
- ASP.NET - Code Samples - Disable CheckboxList Items
- ASP.NET CheckBoxList 用javascript 实现全选
- ASP.NET中WebForm组件CheckBoxList编程
- Asp.net(C#/2.0) 部分全选 CheckBoxList
- asp.net的checkboxlist绑定数据
- Asp.net 中CheckBoxList 的应用
- 用代码压缩Access数据库时遇到的密码问题解决。
- PETSHOP4.0学习札记一 反射
- 一篇震撼中国所有教师的演讲
- 教你设置淘宝店铺收藏代码
- [API学习]删除、复制、重命名、移动文件
- asp:CheckBoxList
- [原创]信息系统,黑匣子与绑架
- 新手上路
- Eclipse SNV+Google code在网上托管项目
- 提高无线网络速度和距离的实用技巧
- 3dmax如何导出virtool模型
- filter:alpha(opacity=100,style=1)opacity属性和style属性
- How to make apache start at boot time
- 手动设置WRE54G