title: Persisting DataSource in GridView after PostBack
body: <p>So I have a GridView in my ASPX page.</p>
  
  <p>When I click <code>&lt;asp:Button id="btnBindIt" runat="server" /&gt;</code> it binds a datatable as follows:</p>
  
  <pre><code>theDataTable = GetAllTheRecords();
  gvTheGridView.DataSource = theDataTable;
  gvTheGridView.DataBind();
  </code></pre>
  
  <p>Note: <code>theDataTable</code> is a member</p>
  
  <pre><code>private DataTable theDataTable;
  </code></pre>
  
  <p>This works as expected.</p>
  
  <p>Now, after the GridView is displayed nicely, I want to export the data to CSV, so I now click the <code>&lt;asp:Button id="btnExportIt" runat="server" /&gt;</code> which runs the code:</p>
  
  <pre><code>exportToCsv(theDataTable);
  </code></pre>
  
  <p>but <code>theDataTable</code> is null.</p>
  
  <p>So I tried</p>
  
  <pre><code>exportToCsv(gvTheGridView.DataSource)
  </code></pre>
  
  <p>Which is also null.</p>
  
  <p>What's the standard way of persisting this data? I don't really want to hit the DB again as it's quite a long SPROC and the user has already waited once.</p>
  
  <p>Thanks in advance!</p>