title: Export gridview data to a excel sheet is giving error
body: <p>I have a asp.net application where in i am displaying a grid view whose code is shown below</p>
  
  <pre><code> &lt;center&gt;&lt;asp:GridView ID="GridView1" runat="server" 
          RowStyle-HorizontalAlign="Center" CellPadding="4" ForeColor="#333333" 
           GridLines="None"&gt;
   &lt;AlternatingRowStyle BackColor="White" /&gt;
      &lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
      &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
      &lt;PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /&gt;
  &lt;RowStyle HorizontalAlign="Center" BackColor="#FFFBD6" ForeColor="#333333"&gt;&lt;/RowStyle&gt;
      &lt;SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /&gt;
      &lt;SortedAscendingCellStyle BackColor="#FDF5AC" /&gt;
      &lt;SortedAscendingHeaderStyle BackColor="#4D0000" /&gt;
      &lt;SortedDescendingCellStyle BackColor="#FCF6C0" /&gt;
      &lt;SortedDescendingHeaderStyle BackColor="#820000" /&gt;
      &lt;/asp:GridView&gt;
   &lt;/center&gt;
   &lt;center&gt; &lt;table&gt;
   &lt;tr&gt;
   &lt;td&gt;
      &lt;asp:Button ID="btnWordConvert" runat="server" Text="Button" 
          onclick="btnWordConvert_Click" /&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/center&gt;
  </code></pre>
  
  <p>in cs</p>
  
  <pre><code> protected void btnWordConvert_Click(object sender, EventArgs e)
  {
      GridView1.AllowPaging = false;
      GridView1.DataBind();
      Response.ClearContent();
      Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.doc"));
      Response.Charset = "";
      Response.ContentType = "application/ms-word";
      StringWriter sw = new StringWriter();
      HtmlTextWriter htw = new HtmlTextWriter(sw);
      GridView1.RenderControl(htw);
      Response.Write(sw.ToString());
      Response.End();
  
  }
  </code></pre>
  
  <p>i am getting error on <code>GridView1.RenderControl(htw);</code> line and the error is <code>Control 'ctl00_ContentPlaceHolder1_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.</code> Any help are appreciated.</p>