Click here to Skip to main content
16,020,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 dropdown boxes dropdown1 and dropdown 2 .... i want to show dropdown 2 items values same as dropdown 1...

XML
<div>
       <asp:DropDownList ID="DropDownList1" runat="server">
           <asp:ListItem>A</asp:ListItem>
           <asp:ListItem>B</asp:ListItem>
           <asp:ListItem>C</asp:ListItem>
           <asp:ListItem></asp:ListItem>
       </asp:DropDownList>
       <asp:DropDownList ID="DropDownList2" runat="server">
       </asp:DropDownList>
   </div>




C#
protected void Page_Load(object sender, EventArgs e)
{
    // Code for show DropDownList2 values from DropDownList1

}
Posted

1 solution

Try this.

C#
foreach(ListItem item in DropDownList1.Items)
                DropDownList2.Items.Add(item);
 
Share this answer
 
Comments
sat_100m 11-Jun-11 3:38am    
Thnx

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