Click here to Skip to main content
15,908,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
        <asp:ListItem>--select university--</asp:ListItem>
        <asp:ListItem Value="1">MIT</asp:ListItem>
        <asp:ListItem Value="2">Oxford</asp:ListItem>
        <asp:ListItem Value="3">Melbourne</asp:ListItem>
    </asp:DropDownList>
    <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True">
        <asp:ListItem>--select country--</asp:ListItem>
        <asp:ListItem Value="1">USA</asp:ListItem>
        <asp:ListItem Value="2">UK</asp:ListItem>
        <asp:ListItem Value="3">Australia</asp:ListItem>
    </asp:DropDownList>
    <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
        <asp:ListItem>--select continent--</asp:ListItem>
        <asp:ListItem Value="1">America</asp:ListItem>
        <asp:ListItem Value="2">Europe</asp:ListItem>
        <asp:ListItem Value="3">Asia</asp:ListItem>
    </asp:DropDownList>


QUESTION
How can I code in the back-end such that when "MIT" is selected in dropdownlist1, "USA" and "America" are automatically selected in dropdownlist2 and dropdownlist3 respectively. likewise to "Oxford" and "Melbourne".

Thank you.
Posted

 
Share this answer
 
Comments
Member 11911171 17-Aug-15 2:59am    
Thanks Abhinav, but how can I code it such that selections in dropdown2 and 3 are automatically done when I make a selection in dropdown1...I am looking not to necessarily scroll the dropdownlist2 and 3. Thanks.
As per my assumption if this data is static data then you can do like this way.


first Create an selected_indexchanged event for dropdown list1.

In That method you can do like this

C#
Public void dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
    {
if(dropdownlist1.selectedIndex!=0)
{
dropdownlist2.selectedIndex= dropdownlist3.selectedIndex=dropdownlist1.selectedIndex;
}


Try this once :)
 
Share this answer
 

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