Home > DeveloperSection > Forums > How to export selected data from my ASPx DevExpress gridview
Mark Devid
Mark Devid

Total Post:101

Posted on    February-09-2014 11:16 PM

 C# C# 

 1 Reply(s)
 5057  View(s)
Rate this:

I need to export to XLS the selected row of my DevExpress GridView. When i try to export my grid, it creates an empty file. I think it is due to the callback that clear the data in my grid before exporting.

This is samples of my ASPx page.

The Load data button

 <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Styles/Images/load.png" onclick="ImageButton1_Click" />

The gridview

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


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


            <dx:GridViewDataTextColumn Caption="Category" VisibleIndex="1" FieldName="category"

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


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



        <SettingsPager PageSize="100">


        <Settings ShowFooter="True" />


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



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">



Now the code behind.

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

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)




I create my datas in a DataTable Object. And then i bind my dataTable with my grid.

grid.DataSource = fakes;


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

    protected void createFile_Click(object sender, EventArgs e)




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.

Pravesh Singh

Total Post:411

Posted on    February-09-2014 11:44 PM

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;       




Don't want to miss updates? Please click the below button!

Follow MindStick