HOW TO: Add a default ListItem to a DropDownList

Rate It (3)

Last post 10-09-2009 11:48 AM by willie55. 15 replies.

Sort Posts:

  • Re: HOW TO: Add a default ListItem to a DropDownList

    10-09-2009, 11:48 AM
    • Member
      8 point Member
    • willie55
    • Member since 10-30-2007, 10:09 AM
    • Posts 4

    Ryan,


    thank you so much.  This solution works beautifully!


    In .NET 2.0, this can be done declaratively using the AppendDataBoundItems property. This will append all data-bound ListItems to the DropDownList, leaving those you add manually as the first selections.

    <asp:DropDownList ID="DropDownListID" AppendDataBoundItems="true" runat="server">
         <asp:ListItem Text="Default text" Value="Default value" />
    </asp:DropDownList>


Page 2 of 2 (16 items) < Previous 1 2