SPGridview is not exporting filtered row into excel RRS feed

  • Question

  • Hi,

    I have SPGridView in that gridview i am using filter features of sharepoint.I have to export Gridview data to excel.My problem is when i filter data and click on excel icon to export only filtered data into excel. but it is exporting all gridview row not the filtered row.Please provide me the best solution for the same.



    Thursday, July 14, 2016 6:15 AM


  • Hi Masroorul,

    Is the SPGridview a custom list view or some custom control in SharePoint web part ?

    If it is SharePoint OOB custom list, then I suggest you can create a new view with filter condition and then use Ribbon button "Export to Excel" to export the filtered items to excel.

    If it is the custom control in web part, I would suggest you can also create a new list view and then bind the new view data to the SPGridView as datasource, then use C# code to loop the item collection to export to excel.

    Here are some code demos for your reference:

    SPGridView bind with list view

    Export SPGridView to Excel spreadsheet


    Best Regards

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Friday, July 15, 2016 6:26 AM