title: Data export from a gridview to Excel in ASP.NET
body: <p>Data transfer grid view to Excel sheet in ASP.NET; how to solve this type of problem
  Error is</p>
  
  <pre><code>Control 'ContentPlaceHolder1_gvdetails' of type 'GridView' must be placed inside a form  tag with runat=server.
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>    Response.ClearContent();
      Response.Buffer = true;
      Response.AddHeader("content-disposition", string.Format("attachment; filename={0}",
      "Customers.xls"));
      Response.ContentType = "application/ms-excel";
      StringWriter sw = new StringWriter();
      HtmlTextWriter htw = new HtmlTextWriter(sw);
      gvdetails.AllowPaging = false; gvdetails.DataBind();
      gvdetails.HeaderRow.Style.Add("background-color", "#FFFFFF");
      gvdetails.RenderControl(htw);
      Response.Write(sw.ToString());
      Response.End();
  </code></pre>