Wednesday, November 25, 2009

How do you add drop down items to a drop down which uses a datasource

Ran into this the other day. I'm filling a drop down (combo box) from the code behind using a datasource. But, the data source of course doesn't include a default or empty value for the top of the list. So, what do you do?

What you can do is on the aspx file add the attribute AppendDataBoundItems="true".
Once you have added this attribute to the drop down (combo box), you can add a new drop down item to the combo box.
Example:

No comments: