Search code examples
asp.netdrop-down-menusqldatasource

How to add a "Select All" entry to a Dropdownlist tied to SQLDataSource?


I hvae a dropdownlist tied to a SQLDataSource that returns a list of Categories. Since this is used as part of a search function, how do I add a "Select All" category and ensure that such a selection queries all categories?

Thanks much!!


Solution

  • I sometimes use sql for this:

    select value, description from reference_table
    union
    select -1, 'Select all'
    Order by 2
    

    There is also the way where you add the item in the markup, then set the AppendDataBoundItems="true"

    Also, see this similar question and answer