ASPNET Quick Tip: adding a static item to a databound dropdownlist

If you would like a dropdown that displays one static item suchas  “–Choose One—“ while the rest of theitems are data bound, then check out the code below:

<asp:DropDownList ID="drpProucts"runat="server"

    DataSourceID="ProductsDS" DataTextField="ProductName" DataValueField="ProductId"

    Width="150px" AppendDataBoundItems="true">

    <asp:ListItem Text="--Choose One--" Value=""></asp:ListItem>

</asp:DropDownList>

Set the AppendDataBoundItems property of the dropdown listto True, and add in the static list item. Your dropdown will look something like this:



And there we go!  A dropdown list that also has a static entry stating to the user that s/he should choose an entry from the dropdownlist.