.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

GridView Filtering In ASP.NET

Posted By: Rahul     Posted Date: November 13, 2009    Points: 2   Category :ASP.Net
In this tutorial you will learn how to add a filter to a Grid View Control, To modify the query with a parameterized filter, the WHERE Clause, Parameter properties, Parameter Value Editor and To test filtering.

View Complete Post

More Related Resource Links

gridview filtering using a codebehind (textbox + search button)

i am trying to replicate the following sequence: input text into text box > press search button > search a database using LIKE operator > display using a gridview or listview. this sequence is fairly easy to do using the drag and drop then sqldatasource options, but i am trying to do the same result using a codebehind.  here is my code:   ____________________________________________________________________________________________________________ SqlConnection myConn; myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\projectDB.mdf; Integrated Security=True;User Instance=True"); myConn.Open(); string strSQL; strSQL = "SELECT * FROM Message";       //strSQL = "SELECT * FROM Message WHERE Message LIKE '" + txtSearch.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(strSQL, myConn); DataSet ds = new DataSet(); da.Fill(ds, "Message"); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); _____________________________________________________________________________________________________________  now, if I use this code inside a page_load event, it does work. if I put it inside a button_click event i get nothing. i am mystified by this.. any help? why can't i use a button to display my gridview1 when i'm using a code behind.  

Filtering GridView?

I have a web page with a GridView control populated from a database.  I want to have a form that users can use to filter the results presented in the GridView.  For example, it might have fields for last name, first name, department, wages, date of hire, etc. that the user can fill out to filter the results.  Is there an elegant way of doing this?  The only thing that comes to mind is to test the value of each field and then have a database query string for every outcome.  For example, if the user only inputs a last name, the query might be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName.  If they input both last name and department, the query would be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName AND Department = @Department.  This seems like it would get unwieldy very quickly.  Any suggestions on a better method? 

Filtering with gridview + (search function)

      have a gridview and  6 dropdownlists which I want to use to filter data in gridview I am using this code below Try            strSql = "Select * from aspnet_Users where UserName = " & Me.DropDownList1.SelectedItem.Text            Call OpenConnection()            Call GiveCommand(strSql)            sqlMyCmd.ExecuteNonQuery()            Me.GridView1.DataSource = sqlMyCmd.ExecuteReader            Me.GridView1.DataBind()            Call EndConnect()        Catch ex As InvalidOperationException        Catch ex2 As SqlException        Catch ex As NullReferenceException        End Try what im trying to acheive on the page is to allow user to pick a value from any1 of the 6 dropdownlist (representing  6 fields) and when btnSearch is clicked Gridview displays the data the code I have above allows me to do this with one dropdown

Need help with filtering a gridview!


 I already kno wthe very basics, I have a few textbox with an autopost back, and they are setup so when the user enters a string and tabs out of the textbox, what they entered goes into my query parameters, thus filtering the data. Simply Right? The problem I'm having is that I want to filter for a quote number. If the user knows the Quote number they enter it and away we go. However I found that if they don't enter a Quote # and that field/textbox is left blank, none of the other filters work. I'm assuming this is an issue with my query but I just can't figure out how to fix it. Any ideas???

Here is my quesy as of right now:

SELECT Quote#, Date, Company, PU1FromTown, PU1FromState, PU1FromZip, PU1ToTown, PU1ToState, PU1ToZip, PU2FromTown, PU2FromState, PU2FromZip, PU2ToTown, PU2ToState, PU2ToZip, PU3FromTown, PU3FromState, PU3FromZip, PU3ToTown, PU3ToState, PU3ToZip, PU4FromTown, PU4FromState, PU4FromZip, PU4ToTown, PU4ToState, PU4ToZip, Pieces, Weight, Commodity, Rate, RatePer, AccessorialCharges, FSCPercentage, FreightCharges, Notes, ServiceType, [3rdPartyCarrier], CarrierPhone, CarrierFax, CarrierNote, AccessorialPayables, FSCPayables, FreightPayables, NotesPayables FROM Quotes

WHERE (Company = ISNULL(@Company, Company) OR Company LIKE '%' + @Company + '%')
AND ([3rdPartyCarrier] = ISNULL(@3rdpartycarrie

how to enable filtering on user setting stored in profile as binary data in a gridview?



I have a Profile with a Property like this:


    <add name="UserDetails" type="oUserDetails" serializeAs="Binary"/>


How can I show all Users with their Details in a GridWiew and how to enable filtering for values located in the UserDetails class. For example UserDetails.FavouriteColor which is a string.



Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

Sortable GridView using jQuery's TableSorter

This article explains how to use jQuery's plug-in Tablesorter to implement client-side sorting in an ASP.NET GridView. This comes in handy especially when an ObjectDataSource is used with a GridView as GridView does not provide sorting out of the box.

Sorting Gridview using Jquery with ASP.NET

I want to show how to sorting a gridview using a Jquery in ASP.NET, it is a flexible client-side table sorting. We have known that Jquery is a new kind of Javascript Library. You can find detail of Jquery in this site http://jquery.com/ there are lot of example with documentation and also allow free download a latest version.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend