![](/img/trans.png)
[英]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.