title: How to export selected data from my ASPx DevExpress gridview
body: <p>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. </p>
  
  <p>This is samples of my ASPx page.</p>
  
  <p>The Load data button</p>
  
  <pre><code> &lt;asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Styles/Images/load.png" onclick="ImageButton1_Click" /&gt;
  </code></pre>
  
  <p>The gridview</p>
  
  <pre><code>&lt;dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="car"&gt;
          &lt;Columns&gt;
              &lt;dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Caption=""&gt;
              &lt;/dx:GridViewCommandColumn&gt;
              &lt;dx:GridViewDataTextColumn Caption="Category" VisibleIndex="1" FieldName="category"
                  Name="category" GroupIndex="0" SortIndex="0" SortOrder="Ascending"&gt;
              &lt;/dx:GridViewDataTextColumn&gt;
              &lt;dx:GridViewDataTextColumn Caption="Car" VisibleIndex="2" FieldName="car" Name="car"&gt;
              &lt;/dx:GridViewDataTextColumn&gt;
          &lt;/Columns&gt;
          &lt;SettingsPager PageSize="100"&gt;
          &lt;/SettingsPager&gt;
          &lt;Settings ShowFooter="True" /&gt;
  
          &lt;GroupSummary&gt;
              &lt;dx:ASPxSummaryItem FieldName="car" SummaryType="Count" /&gt;
          &lt;/GroupSummary&gt;
  
      &lt;/dx:ASPxGridView&gt;
  </code></pre>
  
  <p>The GridExporter</p>
  
  <pre><code>    &lt;dx:ASPxGridViewExporter ID="gridExport" runat="server" GridViewID="grid" ExportedRowType="Selected" /&gt;
  </code></pre>
  
  <p>The create file button</p>
  
  <pre><code>&lt;dx:ASPxButton ID="createFile" runat="server" Text="Create File"      UseSubmitBehavior="False" OnClick="createFile_Click"&gt;
                      &lt;Image Url="~/Styles/Images/save.png"&gt;
                      &lt;/Image&gt;
      &lt;/dx:ASPxButton&gt;
  </code></pre>
  
  <p>Now the code behind.</p>
  
  <p>When I click the load button, i create fake datas for my tests.</p>
  
  <pre><code>    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
      {
          CreateFakeData();
      }
  </code></pre>
  
  <p>I create my datas in a DataTable Object. And then i bind my dataTable with my grid.</p>
  
  <pre><code>grid.DataSource = fakes;
  grid.DataBind();
  </code></pre>
  
  <p>Everything seem to works great but when i click the export button, nothing is exported. </p>
  
  <pre><code>    protected void createFile_Click(object sender, EventArgs e)
      {
          gridExport.WriteXlsToResponse();
      }
  </code></pre>
  
  <p>I followed the <a href="http://demos.devexpress.com/aspxgridviewdemos/exporting/ExportSelected.aspx" rel="nofollow">DevExpress tutoria to export selected rows in ASPl</a>. But it seems that my page is refreshed so i loose the data binded with the grid before the export. </p>