Adding New items in DropDown

Sandhyab
Posted by Sandhyab under ASP.NET category on | Points: 40 | Views : 896
 <asp:DropDownList ID="drpdwn" runat="server"></asp:DropDownList>


protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
for (int i = 0; i < 5; i++)
{
drpdwn.Items.Add(new ListItem("Item" + i, i.ToString()));
}
drpdwn.Items.Insert(3, new ListItem("Item -1", "3" ));

}

Comments or Responses

Login to post response