I have a ASP DropDownList with items added to it. All what I want is to make the selection after the page loaded empty so there is no a selected item.
How can I do that?
I have a ASP DropDownList with items added to it. All what I want is to make the selection after the page loaded empty so there is no a selected item.
How can I do that?
You can set the
SelectedIndex
property to -1 or you can add an empty entry as the first item in the data source and validate the selection on form submission.This should work on the client side:
Not sure I understand your question but try this:
or
If the dropdownlist is being populated by DataSource, is important do the DataBind before the insert. Otherwise the item insertion does not happen.
https://stackoverflow.com/a/2224636/1467453
You can add an empty item to the top of your dropdownlist programmatically like this:
yourDropDownList.Items.Clear()
To repopulate, you can either add items statically as per womps suggestion (substituting params in the
insert()
method, or you can populate it dynamically from a data source. The backing store for list items is the ListItemCollection.