When I clicking Print button excel sheet is not getting but data is binding correctly. protected void btnReturn_Click(object sender, EventArgs e) { Response.Redirect("~/Mail/ManageTrainingSeminar.aspx"); }
protected void btnPrintExcel_Click(object sender, EventArgs e) { Int16 Id = Convert.ToInt16(Request.QueryString["ID"]); //Get the data from database into datatable DataTable dt = MailDistributionManager.GetTrainingEventsListETE(Id);
//Create a dummy GridView GridView GridView1 = new GridView(); GridView1.AllowPaging = false; GridView1.DataSource = dt; GridView1.DataBind();
Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter();< ...

Go to the complete details ...