gjshah7254
7/21/2015 - 9:01 PM

Dynamically add items to a dropdownlist c#add items to a dropdownlist c#

Dynamically add items to a dropdownlist c#add items to a dropdownlist c#

<asp:DropDownList ID="drpCategories" runat="server" OnSelectedIndexChanged="drpCategories_SelectedIndexChanged" AutoPostBack="true">
      <asp:ListItem Text="Show all:" Value=""></asp:ListItem>
</asp:DropDownList>

//In Code behind file
drpCategories.Items.Add(new ListItem("Text Name", "Value Name"));