Coding Thread, filtering datagrid with combo box in Coding and Web Development; Hi there.
I currently have an application where a user can select items from a combo box and then display ...
5th January 2009, 02:21 PM #1
filtering datagrid with combo box
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.
IDG Tech News
5th January 2009, 05:08 PM #2
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
By Shrimpersfan in forum Coding
Last Post: 23rd December 2008, 07:38 PM
Last Post: 22nd July 2008, 09:33 PM
By Ben_Stanton in forum How do you do....it?
Last Post: 4th December 2007, 09:49 AM
By rhyds in forum Hardware
Last Post: 6th November 2007, 11:39 AM
By CM786 in forum Wireless Networks
Last Post: 6th August 2006, 08:20 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)