Click here to Skip to main content
Click here to Skip to main content

GridView Multiple Filter AJAX Control

By , 14 Jun 2008
 

FilterDemo1.PNG

FilterDemo2.PNG

FilterDemo3.PNG

Introduction

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.

Source Code and Video

I have uploaded the source code and a Flash video on how to use the control inside your web application, on my blog. To run the video, you have to have the Flash plug-in in your browser. Drag and drop the SWF file inside your browser and it will run: http://tawatech.blogspot.com/2008/06/aspnet-datagridview-ajax-data-filter.html.

Background

I was looking for an ASP.NET 2.0 custom control that enables the user to filter data in a GridView control by adding filters to the GridView. Similar controls can be found in applications such as Microsoft BI Studio. So I decided to develop a web based control that will do such thing.

Using the Code

To use the control is very straightforward:

  1. Add web.config AJAX tags to enable AJAX in your website:
  2. Drag and drop the filter control in your page. (Note: the control already has the AJAX UpdatePanel and ScriptManager, you don't have to create a new UpdatePanel for the control.)

    ControlPage.png

  3. Drag and drop an UpdatePanel for the GridView.
  4. Place the GridView inside the AJAX UpdatePanel and specify the SQLDataSource for it.
  5. TestPage.png

    Note: The control already has a ScriptManager, so you don't have to create one in your ASPX page.

  6. On Page_Load, specify the DataSource and DataColumns for the filter control and specify the event handler method that will be called after adding or removing the filter.
  7. Page_Load.png

  8. Calling the control method FilterDataSource() in the event handler tableFilter_OnRefresh() will apply the filter on the SqlDataSource1 that you have assigned to the GridView.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

tawammar
Web Developer
Jordan Jordan
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionnice articlememberMember 382310126 Oct '12 - 21:22 
This is really nice article.
 
You can check this article
 
http://dotnetpools.com/Article/ArticleDetiail/?articleId=52&title=Ajax%20AsyncFileUpload%20Example%20In%20Asp.net%20To%20Upload%20Files%20To%20Server%20Using%20AjaxFileUpload%20Control[^]
GeneralMy vote of 5memberhadi552610 Jul '12 - 19:31 
احسنت !
QuestionVB.Net CodememberOnyebuchim6 Mar '12 - 23:55 
Hi,
 
Great work. Please could you recode the program to VB.Net.
 
Thanks
QuestionMy vote is 5membermuhamd yusuf21 Feb '12 - 20:26 
thanks for your work
Smile | :)
GeneralMy vote of 5membereshaq13 Jun '11 - 11:42 
Good work, Thank you.
Generalpopulate Gridview with Multiple Filter Options !!memberrocky81122 Apr '10 - 5:38 
HI ,
 
I have a grid which displays a set of columns and I m trying to display only those rows in grid based on the options chosen or searched.
 
My filter options are
1) search for (textbox) - search from (listbox with columns product, product id , userid )
2) Date filter - choose 1 checkbox out of 3 checkboxes(create Date, submit date, Approve ) and whateevr is selected for the criteria we choose between date from and to calender.
3) Status - listbox with status ID 's
 
Basec on this three filter options I need to frame a LINQ to SQL query that gives me results in grid any option can either be choosen or can be left blank I am using 3 - tier architecture and passing all this fields as parameters in a method from UI.cs to UI.DAL where I am writing a query to generate grid view rows. I think I need to use Dynamic LInq and I have not done that before !!
 
Can someone help me on this !!
GeneralNice workmemberhaitham hamed housin15 Apr '10 - 14:33 
I really like it , keep good working.
amazing control wish Microsoft add this feature.
Generaldatabindingmemberykpatel29 Sep '09 - 3:21 
Hi everyone,
 
I have three dropdownlists and one datagrid
My problem is-when i select values from 3 ddls and click on search button it doesnt display related records.it just shows all records.
 
what i need is-
I want to display matching records ( match keywords) in datagridview selected from all dropdownlists.
 
tHANKS
QuestionNew release?memberangel.escamilla6 Apr '09 - 18:24 
Hi Ammar,
 
I read on your blog about your new release, I would very much like to see it. Can you post it on your blog or in here?
 
thanks,
 
Angel
Questionc# Sources ?memberDavid Zenou21 Jul '08 - 23:54 
Have you got c# project sources ?Cool | :cool:
 
Si tu aimes ce que tu fais , tu finis par réussir !
(french proverb)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 15 Jun 2008
Article Copyright 2008 by tawammar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid