Tuesday, September 16, 2008

Default value for a dropdown list

Its a small add-in in Asp.net 2 and later but I find it very useful. If you have a dropdown list which you bind with data from a database or other source and want to add a default item as well like "Please select an item", it could be easily done with a new property AppendDataBoundItems property of dropdownlist. Simply set it to true while declaring the list and add you default item in it.

When you will this list with a data source the first item would still be there.

No comments: