blade33
blade33

Reputation: 131

How to set the default item in a drop down list and make it appear at the top?

I have a set of drop down boxes which are bound to the folder names in a folder (via getting all the directories, and then their lastnames, and then bind this array to the drop down list).

However, I also add an entry called "Please select..." after getting the array.

But is there a way to make this selection appear at the top of the drop down list (putting in something like dashes at the start and end don't work), and make it selected by default?

Thanks

Upvotes: 1

Views: 351

Answers (1)

Lazarus
Lazarus

Reputation: 43074

If it is an ArrayList you could use myArray.Insert(0, "My Default Entry") which would make your default the first item in the list. Alternatively, you could set the SelectedIndex of the drop down to the index of your default item.

Upvotes: 1

Related Questions