Ever wanted to add a default “select” item to a listbox after a databind?
The following should do the trick.
DropDownList1.DataSource = YourDataSet;
DropDownList1.DataBind();
// Add Default list item at index 0
DropDownList1.Items.Insert(0, new ListItem("- select -", "0"));
This adds a new item with a text title of “- select -” and a value of 0.
No related posts.