Why is the dropdown not showing my blank item first? Here is what I have
drpList.Items.Add(New ListItem("", ""))
With drpList
.DataSource = myController.GetList(userid)
.DataTextField = "Name"
.DataValueField = "ID"
.DataBind()
End With
Edit ~ I am binding to a Generig List, could this be the culprit?
best way is to use $("#dropdownid"). html(''); it makes the value null. This is the only answer here that works when the select does not have a blank option, and in cases where such an option is not desired. The only other way is to add the blank option, as Andy did.
After your databind:
drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
drpList.SelectedIndex = 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With