Protected Void ExportData()
{
Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
string FileName = "Grid" + DateTime.Now + ".xls";
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename="+FileName +"");
grdRetailData.GridLines = GridLines.Both;
grdRetailData.Columns[1].Visible = false;
grdRetailData.HeaderStyle.Font.Bold = true;
grdRetailData.RenderControl(htmltextwrtter);
grdRetailData.AllowPaging = false;
BindData();
Response.Write(strwritter.ToString());
Response.End();
}