string strN = "";
        for (int i = 0; i < chklstN.Items.Count; i++)
        {
            if (this.chklstN.Items[i].Selected)
                strN += chklstN.Items[i].Value+";";
        }已经全部将复选框选中,并且AutoPostBack也设为了false,但循环中的每一个this.chklstN.Items[i].Selected都为false,
不知是什么原因?

解决方案 »

  1.   

     if (this.chklstN.Items[i].Checked)
      

  2.   

    可checkboxlist的Items[i]无Checked属性
      

  3.   

    if (this.checkedListBox1.CheckedItems.Count > 0)
                {
                    foreach (string item in this.checkedListBox1.CheckedItems)
                    {
                        ……………………
                    }
                }
      

  4.   

    …………搞错了!是WEB的!哎
      

  5.   


    楼主 在.net里 按个.看看出来的属性,一般问题都可解决
      

  6.   

    代码放在确定按钮的click事件中:
        protected void btnOk_Click(object sender, ImageClickEventArgs e)
        {
            string strN = "";
            for (int i = 0; i< chklstN.Items.Count; i++)
            {
                if (this.chklstN.Items[i].Selected)
                    strN += chklstN.Items[i].Value+";";
            }
            ... ...
        }
      

  7.   

     protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.CheckBoxList1.Items.Add("vv");
                this.CheckBoxList1.Items.Add("ss");
                this.CheckBoxList1.Items.Add("mm");
            }
            for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
            {
                this.CheckBoxList1.Items[i].Selected = true;
            }    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.CheckBoxList1.Items.Count; i++)
            {
                if (this.CheckBoxList1.Items[i].Selected)
                {
                    string ss = "";
                    ss += this.CheckBoxList1.Items[i].Value;
                    Response.Write(ss);
                }
            }
        }
      

  8.   

    以解决问题了
    原因:checkboxlist的item的加载是在page_load中
    在page_load()中忘了做if (!IsPostBack)的判断了...
      

  9.   

    if(!ispostback)
    {
    checkboxlist绑定
    }
    就可以了