Hye all, I want to Export All Data (Paging in a Gridview ) To Excel sheet.
Current Status: Export Data Working But getting only 1 Page data when i am into that page
I want to export data ( Data in all pages ) into excel sheet ..
Hye all, I want to Export All Data (Paging in a Gridview ) To Excel sheet.
Current Status: Export Data Working But getting only 1 Page data when i am into that page
I want to export data ( Data in all pages ) into excel sheet ..
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.
Sachin SinghPosted Nov 10, 2022, 9:08 AM
see,
Tell me first thing, when your binding data to your gridview then are you fetching all data or just page size (say 10) ? Or you are fetching all at once then gridview is doing pagination for you?
If you are fetching all records at once then simply use that SP to export to excel with below method, or create one additional SP to get all records.
Just pass the dataset to above method and it will work fine. I often use this method.
Uday DodiyaPosted Nov 10, 2022, 6:58 AM
Hi Deepak,
Use following code, you get exact output
HTML Markup
The following HTML Markup consists of an ASP.Net GridView control with three BoundField columns and a Button.
Paging has been enabled for the GridView control.
Namespaces
You will need to import the following namespaces
Populating the GridView control
Inside the Page Load event, the GridView is populated with records from the Customers Table of the Northwind Database.
Implement Paging in GridView
The OnPageIndexChanging event handles the Pagination in the GridView.
Inside the OnPageIndexChanging event handler, the GridView’s PageIndex property is updated and the GridView is again populated from Database by making call to the BindGrid method.
Export GridView with Paging Enabled to Excel
When the Export Button is clicked, first the Content Type is set in the Response Stream in order to specify the Browser that the downloading file is an Excel file.
The Paging is disabled for the GridView by setting the AllowPaging property to False and the GridView is again populated with records from the Database.
Then a loop is executed over the GridView rows and the style and formatting are applied to the Row and Alternating Row of the GridView control.
Vishal YelvePosted Nov 10, 2022, 6:37 AM
Hi Deepak,
try bootstrap-table, Please refer below link
https://examples.bootstrap-table.com/index.html#extensions/export.html
Vishal JoshiPosted Nov 10, 2022, 6:25 AM
Export one excel from multiple paged gridview, just use these line before calling the convert function "ExportToExcel()".