[英]I want to add CheckBox Value into DataGridView without Database in C#
[英]I have problem to add checkbox selected to database using c#
任何人都可以帮我吗…………我让这个结尾把它添加到数据库中的问题只是第一行而不是全部检查
` for(int i =0; i < CheckBoxList1.Items.Count; i++)
if (CheckBoxList1.Items[i].Selected == true)
{
SqlParameter[] CommandParameter = new SqlParameter[3];
CommandParameter[0] = new SqlParameter("DMLType", "Insert");
CommandParameter[1] = new SqlParameter("@Work_DoctorID", Request.QueryString["ID"].ToString());
CommandParameter[2] = new SqlParameter("@Work_WorkDayes", CheckBoxList1.Items[i].Text);
dt = db.ExecSp("AllWorkingDayes", CommandParameter);
if (dt != null && dt.Rows.Count > 0)
{
Response.Redirect("?type=All");
}
else
{
Label1.Text = "خطأ في الاضافه";
}`
只需更改此代码
if (CheckBoxList1.Items[i].Selected == true)
到
if (CheckBoxList1.Items[i].Checked)
如果使用布尔值还有另一个提示:可以不添加比较,因为它已经是真或假
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.