---
title: "How to export selected data from my ASPx DevExpress gridview"  
description: "How to export selected data from my ASPx DevExpress gridview"  
author: "Mark Devid"  
published: 2014-02-09  
updated: 2014-02-09  
canonical: https://www.mindstick.com/forum/1963/how-to-export-selected-data-from-my-aspx-devexpress-gridview  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to export selected data from my ASPx DevExpress gridview

I need to export to XLS the selected row of my [DevExpress](https://www.mindstick.com/forum/34326/fill-devexpress-gridview-with-list) [GridView](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net). When i try to export my grid, it creates an empty file. I think it is due to the [callback](https://www.mindstick.com/articles/152/using-the-callback) that clear the data in my grid before exporting.

This is samples of my [ASPx page](https://www.mindstick.com/forum/218/how-do-i-create-an-aspx-page-that-periodically-refreshes-itself).

The Load data button

<asp:[ImageButton](https://www.mindstick.com/articles/12753/imagebutton-in-android) ID="ImageButton1" runat="server" ImageUrl="~/Styles/Images/load.png" [onclick](https://www.mindstick.com/forum/12718/onclick-for-hyperlink)="ImageButton1_Click" />

The gridview

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="car">

<Columns>

<dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Caption="">

</dx:GridViewCommandColumn>

<dx:GridViewDataTextColumn Caption="Category" VisibleIndex="1" [FieldName](https://www.mindstick.com/forum/34722/how-to-get-label-text-from-table-reference-on-database-based-on-tablename-and-fieldname)="category"

Name="category" GroupIndex="0" SortIndex="0" SortOrder="Ascending">

</dx:GridViewDataTextColumn>

<dx:GridViewDataTextColumn Caption="Car" VisibleIndex="2" FieldName="car" Name="car">

</dx:GridViewDataTextColumn>

</Columns>

<SettingsPager PageSize="100">

</SettingsPager>

<[Settings](https://www.mindstick.com/blog/63563/steps-to-change-the-wireless-settings-using-linksys-cloud-account) ShowFooter="True" />

<GroupSummary>

<dx:ASPxSummaryItem FieldName="car" SummaryType="Count" />

</GroupSummary>

</dx:ASPxGridView>

The GridExporter

<dx:ASPxGridViewExporter ID="gridExport" runat="server" GridViewID="grid" ExportedRowType="Selected" />

The create file button

<dx:ASPxButton ID="createFile" runat="server" Text="Create File" UseSubmitBehavior="False" OnClick="createFile_Click">

<Image Url="~/Styles/Images/save.png">

</Image>

</dx:ASPxButton>

Now the [code behind](https://www.mindstick.com/forum/2199/call-javascript-s-function-from-code-behind).

When I click the load button, i create fake datas for my tests.

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)

{

CreateFakeData();

}

I create my datas in a [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) Object. And then i bind my dataTable with my grid.

grid.DataSource = fakes;

grid.DataBind();

Everything seem to works great but when i click the export button, nothing is exported.

protected void createFile_Click(object sender, EventArgs e)

{

gridExport.WriteXlsToResponse();

}

I followed the DevExpress tutoria to export selected rows in ASPl. But it seems that my page is refreshed so i loose the data binded with the grid before the export.

## Replies

### Reply by Pravesh Singh

Hi Mark,

I had a similar situation when I was binding data to an ASPXGridView in the code behind. I was able to solve it by rebinding in the button click, before the export line.

protected void createFile_Click(object sender, EventArgs e)

{

grid.DataSource = fakes;

grid.DataBind();

gridExport.WriteXlsToResponse();

}


---

Original Source: https://www.mindstick.com/forum/1963/how-to-export-selected-data-from-my-aspx-devexpress-gridview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
