I need a custom filter for gridview header, as well as when i search any grid's data my total record count shoud be change.
Loading
I need a custom filter for gridview header, as well as when i search any grid's data my total record count shoud be change.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasad RaveendranPosted Sep 20, 2023, 7:17 PM
To implement a custom filter for each column in a GridView in ASP.NET Web Forms, you can add filter controls (e.g., TextBoxes or DropdownLists) for each column and use them to filter the data accordingly. Here's a step-by-step guide on how to achieve this:
Create Your ASP.NET Web Forms Page: Start by creating an ASP.NET Web Forms page with a GridView control. Add filter controls for each column in the GridView header.
2. Code-Behind: In your code-behind file (e.g.,
YourPage.aspx.cs), handle the logic to apply the custom filters when filter controls change.In this example, we added filter controls (TextBoxes) for the "Name" column. You can add similar filter controls for other columns as needed and adjust the filtering logic accordingly in the
BindGridViewmethod. TheOnTextChangedevent of the filter controls triggers theApplyFiltersmethod, which rebinds the GridView with the filtered data. TheGridView1_RowDataBoundevent ensures that the filter controls' values are maintained when the GridView is reloaded.Cr BhargaviPosted Sep 20, 2023, 10:17 AM
To add a custom filter to a GridView header in ASP.NET, you can create a custom template for the header cell and include your filter controls inside that template. Additionally, you can update the record count when you search the grid's data.
Ali BenchaabanPosted Sep 19, 2023, 12:15 PM
Hello Ranjender,
To achieve yout goal, please try this code below
Create an input element for each column header where you want to provide filtering.
Write JavaScript functions to handle the filtering based on user input.
Update Total Record Count
Display Total Record Count
Finally, an example of C# method you can use it to update the total record