Hi,
For Exporting grid view to excel file use following code
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition","attachment;filename=g.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter ht = new HtmlTextWriter(sw);
gvDisplay.AllowPaging = false;
gvDisplay.DataBind();
gvDisplay.RenderControl(ht);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End()
and just add following metod in aspx.cs page
public override void VerifyRenderingInServerForm(Control control)
{
}
Best Luck
happy Coding