Adding List All to a Drop Down List

I had a dropdownlist that listed all the states, when a state was chosen the SQLDataSource would return the data that matched the states column like this:

SelectCommand="SELECT [FirmName], [Fullname], [EmailAddy], [States] FROM [Experts] WHERE ([States] LIKE '%' + @States + '%')">

Problem was when I added a -List All- choice to the dropdownlist, where I wanted to list all the data about all states. This was easily done with an If statement in the code behind stating that if the selectedvalue of the DDL was “all” then the selectedvalue was now equal to “”. But it didn’t work, I finally found that you needed to add ConvertEmptyStringToNull=”false” to the ControlParameter.

<asp:ControlParameter ControlID="somecontrol" Name="States" DefaultValue="" ConvertEmptyStringToNull="false" PropertyName="selectedvalue"

Technorati Tags: ,


Leave a Reply