We are binding a list of custom objects to an ASP.NET DropDownList in C# but we want to allow for the DropDownList to not have anything selected initially. One way of doing this might be to create an intermediate list of strings, populate the first one with an empty string and then populate the rest of the list with the custom object information.
This doesn’t seem very elegant however, does anyone have a better suggestion?
Yes, create your list like so:
(Note the use of
AppendDataBoundItems='True')And then when you bind, the bound items are put after the empty item rather than replacing it.