且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

选择清单列表中的下拉列表项是否已选中?

更新时间:2022-12-02 10:42:10

使用以下代码..数组列表将保留复选框列表控件中的选定"复选框值

Use the below code .. the array list will hold the Selected check box value from checkbox list control

ArrayList arrList = new ArrayList();
   for(int i=0;i<=CheckBoxList1.Items.Count -1;i++)
    {
        if (CheckBoxList1.Items[i].Selected)
        {
            arrList.Add(CheckBoxList1.Items[i].Value);
        }



}



}


选中此
protected void Button1_Click(object sender, EventArgs e)
   {
       for (int i = 0; i < CheckBoxList1.Items.Count; i++)
       {
           if (CheckBoxList1.Items[i].ToString() == DropDownList1.SelectedItem.Text)
           {
               CheckBoxList1.Items[i].Selected = true;
               break;
           }
       }
   }