1
Answer

dropdownlist selected item in checkedlist box

ajay raju

ajay raju

14y
3.1k
1
hi

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>
    </asp:CheckBoxList>


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.

Thanks
Answers (1)
0
Koteswararao Mallisetti
NA 1.1k 468.9k 14y
take the dropdown values as follows

  <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:ListItem>select Color</asp:ListItem>
        <asp:ListItem>Red</asp:ListItem>
        <asp:ListItem>green</asp:ListItem>
        <asp:ListItem>bluee</asp:ListItem>
    </asp:DropDownList>
&nbsp;<asp:CheckBoxList ID="CheckBoxList1" runat="server">
        <asp:ListItem>Red</asp:ListItem>
        <asp:ListItem>green</asp:ListItem>
        <asp:ListItem>bluee</asp:ListItem>
    </asp:CheckBoxList>
and write the following code in buton click event

if (DropDownList1.SelectedIndex!= 0)
        {
            CheckBoxList1.SelectedIndex = DropDownList1.SelectedIndex-1;
        }

all the best
M.KoteswaraRao.