Click here to Skip to main content
6,821,293 members and growing! (19,726 online)
Email Password   helpLost your password?
Web Development » ASP.NET Controls » Grid Controls     Intermediate License: The Code Project Open License (CPOL)

GridView Multiple Filter AJAX Control

By tawammar

An AJAX control to filter data in a GridView control by adding filters to the GridView at runtime.
C#1.0, C#2.0, C#3.0.NET2.0, ASP.NET, Ajax, Dev
Revision:3 (See All)
Posted:14 Jun 2008
Views:33,641
Bookmarked:53 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
3 votes for this article.
Popularity: 2.39 Rating: 5.00 out of 5

1

2

3

4
3 votes, 100.0%
5

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


Member

Occupation: Web Developer
Location: Jordan Jordan

Other popular ASP.NET Controls articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
Generaldatabinding Pinmemberykpatel4:21 29 Sep '09  
QuestionNew release? Pinmemberangel.escamilla19:24 6 Apr '09  
Generalc# Sources ? PinmemberDavid Zenou0:54 22 Jul '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 14 Jun 2008
Editor: Smitha Vijayan
Copyright 2008 by tawammar
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project