title: Disable paging in GridView to Excel export
body: <p>I've got a function to export some data from the <code>GridView</code> to Excel, which is bound to some checkboxes. So it only exports the rows that are checked.
  This works fine, however I can't seem to disable paging for the export?
  This is my code:</p>
  
  <pre><code> private void ExportGridToExcel()
  {
  
      bool isSelected = false;
      foreach (GridViewRow i in GridView1.Rows)
      {
          CheckBox cb = (CheckBox)i.FindControl("chkSelect");
          if (cb != null &amp;&amp; cb.Checked)
          {
              isSelected = true;
              break;
          }
      }
  
      if (isSelected)
      {
          GridView gvExport = GridView1;
          // this below line for not export checkbox to excel file
          gvExport.Columns[0].Visible = false;
          foreach (GridViewRow i in GridView1.Rows)
          {
              gvExport.Rows[i.RowIndex].Visible = false;
              CheckBox cb = (CheckBox)i.FindControl("chkSelect");
              if (cb != null &amp;&amp; cb.Checked)
              {
                  gvExport.Rows[i.RowIndex].Visible = true;
              }
          }
  
          Response.Clear();
          Response.Buffer = true;
          Response.AddHeader("content-disposition", "attachment;filename=ExportGridData.xls");
          Response.Charset = "";
          Response.ContentType = "application/vnd.ms-excel";
          StringWriter sw = new StringWriter();
          HtmlTextWriter htW = new HtmlTextWriter(sw);
          Response.ContentEncoding = System.Text.Encoding.Unicode;
          Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          gvExport.AllowPaging = false;
          gvExport.RenderControl(htW);
          Response.Output.Write(sw.ToString());
          Response.End();
  
      }
  }
  
  protected void Button3_Click(object sender, EventArgs e)
  {
  
      ExportGridToExcel();
  
  }
  </code></pre>
  
  <p>As you can see I've set <code>AllowPaging = false</code> but the page numbers are still visible in the exported file. Anybody got any idea why?</p>