Sometimes we might just need to add values to a dropdownlist which does not change frequently, hence listitem can solve the problem. Below is an example of populating dropdown list using listitem through coding.

Suppose name of th dropdownlist is drpChooseStatus

List<System.Web.UI.WebControls.ListItem> status = new List<System.Web.UI.WebControls.ListItem>(); status.Add(new ListItem(“In Progress”, “1”)); status.Add(new ListItem(“To be added”, “2”)); status.Add(new ListItem(“Completed”, “3”));
drpChooseStatus.DataSource = status;
drpChooseStatus.DataBind();

Advertisements