Setting a default list item in a drop down list
By Jamsi • Feb 2nd, 2006 • Category: ASP.NETEver 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.
FREE NEWSLETTER -> Want Tech Tips Sent Straight to your Inbox?
Grab our Newsletter to Ensure your PC is Running Smooth!
Jamsi is currently studying a full time Bachelor of Computer/Business degree and working part time as an Internet Security Consultant.
Email this author | All posts by Jamsi























