Add default value for dropdownlist


/ Published in: VB.NET
Save to your folder(s)

Add Item to DropDownList After DataBind


Copy this code and paste it in your HTML
  1. ddlAuthor.DataTextField = "FullName"
  2. ddlAuthor.DataValueField = "AuthorID"
  3. ddlAuthor.DataSource = authorDB.GetAuthors()
  4. ddlAuthor.DataBind()
  5. 'ERROR ---> ddlAuthor.Items.Insert(0, "-- Select Author --")
  6. ddlAuthor.Items.Insert(0, New ListItem("-- Select Author --", "0"))

URL: http://digitalcolony.com/2007/03/add-item-to-dropdownlist-after-databind.aspx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.