I currently have an application where a user can select items from a combo box and then display the results in a datagrid view depending on what is selected in the combo box. This is fine because the user is selcting an exact match from what is in the sql connection but i need the user to be able to select a range from a different combo box, ie - if a field/row in the datagrid is 'Total' then i would want the user to be able to filter out all totals between '100 and 200' or '201 - 300' etc.
I have tried using a case statement but am unsure if this is the right way of going about it.
I'd use two variables for the drop down lists which you want the range for. For example say you have DropLowestRange, DropHighestRange. In the select parameters section of the gridview have the variables similar to lowestVal and HighestVal.
<asp:controlparameter ControlID="DropLowestRange" PropertyName="SelectedValue" Name="lowestVal" />
<asp:controlparameter ControlID="DropHighestRange" PropertyName="SelectedValue" Name="highestVal" />
The SQL query which you can use would then be something to the following:
select * from table where Total<@highestVal and Total>@lowestVal
Note if you want them to have the choice of an exact match, include another variable e.g. DropDownExact. Then use the following sql
select * from table where (Total<@highestVal and Total>@lowestVal) or Total = @DropDownExact
Hope it helps
There are currently 1 users browsing this thread. (0 members and 1 guests)