can any one help me plz............i make this coda put the problem it's add into database just first row not all checked
` 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 = "خطأ في الاضافه";
}`
Just change this code
if (CheckBoxList1.Items[i].Selected == true)
To
if (CheckBoxList1.Items[i].Checked)
And another tip if working with booleans: it's ok to not add a comparison because it's already true or false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.