Click here to Skip to main content
14,980,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi sir,

in my web app i am taken one dropdownlist, button and chekboxList controls. and in dropdownlist items are Red, Blue, Green.

and in checkedlistbox i take items are

<asp:CheckBoxList ID="CheckBoxList1" runat="Server">
        <asp:ListItem Text="Red" Value="red"></asp:ListItem>
        <asp:ListItem Text="Blue" Value="blue"></asp:ListItem>
        <asp:ListItem Text="Green" Value="green"></asp:ListItem>

my aim is when i am selecting Red item in dropdownlist and i click button that time Red checkbox is selected. similarly to all

please give me a solution and please give a some sample code todo this.


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)

check this
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;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900