Link to home
Start Free TrialLog in
Avatar of Anthony_B
Anthony_B

asked on

ASP FilterExpression issue with using an IN statement

I am trying to filter a listing by state using a drop down list of time zones.  I have a database with

Eastern	('ME', 'VT', 'NH', 'MA', 'RI', 'CT', 'NY', 'PA', 'NJ', 'DE', 'MD', 'VA', 'SC', 'GA', 'FL', 'OH', 'WV', 'IN', 'KY')
Central	('TN', 'AL', 'MS', 'LA', 'AR', 'MO', 'IA', 'MN', 'ND', 'SD', 'NE', 'KS', 'OK', 'TX')
Mountain	('NM', 'CO', 'WY', 'MT', 'ID', 'UT', 'AZ')
Pacific	('NV', 'CA', 'OR', 'WA')

Open in new window


and a dropdownlist with the first column as the name and the second as the value.  I have another database that has a huge list of names, addresses and phone numbers, and I want to be able to control what is shown in this other drop down list by the time zone.  Below is my code for the second drop down box.

<asp:SqlDataSource ID="SqlJub" runat="server" 
        ConnectionString="<%$ ConnectionStrings:JubConnectionString %>" 
        SelectCommand="SELECT [Company], [id], [State] FROM [Contacts] WHERE (([call1] IS NULL) AND ([emailed] IS NULL)) ORDER BY [Company]"
        FilterExpression="State in '{0}%'" >
        <FilterParameters>
        <asp:ControlParameter Name="State"  ControlID="DropDownList2" />
        </FilterParameters>

    </asp:SqlDataSource>

Open in new window


Whenever I try to run the above in my web page, it gives me a message "Syntax error: The items following the IN keyword must be separated by commas and be enclosed in parentheses"

Any and all assistance would be appreciated.
Avatar of Alfred A.
Alfred A.
Flag of Australia image

Try the following:

FilterExpression="State IN ('{0}%')"

I hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of Alfred A.
Alfred A.
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial