+ Post New Thread
Results 1 to 2 of 2
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 ...
  1. #1
    Shrimpersfan's Avatar
    Join Date
    Feb 2008
    Thank Post
    Thanked 0 Times in 0 Posts
    Rep Power

    filtering datagrid with combo box

    Hi there.

    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.

  2. #2

    Join Date
    May 2008
    Thank Post
    Thanked 27 Times in 24 Posts
    Rep Power
    Hi there,

    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

+ Post New Thread

Similar Threads

  1. Creating query based on multiple combo boxes
    By Shrimpersfan in forum Coding
    Replies: 8
    Last Post: 23rd December 2008, 07:38 PM
  2. C# Help - Datagrid cell formatting
    By Gatt in forum Coding
    Replies: 6
    Last Post: 22nd July 2008, 09:33 PM
  3. Spam filtering on an exchange 2007 box...
    By Ben_Stanton in forum How do you do....it?
    Replies: 5
    Last Post: 4th December 2007, 09:49 AM
  4. DVD/VHS combo - any ones stand out?
    By rhyds in forum Hardware
    Replies: 1
    Last Post: 6th November 2007, 11:39 AM
  5. SIS 900 LAN and Group Policy = BAD COMBO! Help!
    By CM786 in forum Wireless Networks
    Replies: 19
    Last Post: 6th August 2006, 08:20 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts