protected void Button1_Click(object sender, EventArgs e)
{
this.EnableViewState = false;
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=exp.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter ht = new HtmlTextWriter(sw);
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(ht);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
public override void VerifyRenderingInServerForm(System.Web.UI.Control control)
{
}