title: GridView Export to Excel is exporting entire aspx page
body: <p>I am trying to export a gridview's contents to excel. I have some code:</p>
  
  <pre><code>public void ExcelDownload(object sender, EventArgs e)
      {
          Response.Clear();
          Response.Buffer = true;
          Response.Charset = "UTF-8"; 
          Response.AppendHeader("Content-Disposition", "attachment;filename=MailingList.xls");
          Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
          Response.ContentType = "application/ms-excel";
          this.EnableViewState = false;
          System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("EN-US", true);
          System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
          System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
          MailingList.RenderControl(oHtmlTextWriter);
          Response.Write(oStringWriter.ToString());
      }
  </code></pre>
  
  <p>which runs when a link is clicked. This works fine, except that it is exporting the entire webpage, instead of just the gridview (MailingList). Does anyone know how to fix this?</p>