ASP.NET 2 and dropdownlists

Soldato
Joined
12 Jan 2004
Posts
6,824
Location
Londinium
Hey guys,

i'm trying to add a default item to a dropdown list that is bbound to a data source. I can do this if I bind the ddl to the ds in code, but if I set the ds in the DataSourceID property of the ddl then adding the default option in code does not work (I guess as the ddl is bound after the code to add the default item is run).

I want to reduce the code so I want to be able to use the ddl tag properties to set the ds but need to add the default item somewhere. Can anyone tell me how to do this?
 
Answered my own question! You just add the default list item as normal and then set the AppendDataBoundItems to true. Et viola! :)
 
Back
Top Bottom