Reylin Mathew

Reylin Mathew

  • NA
  • 347
  • 75.5k

Downloading a excel File with a Save As Dialog in c#

Nov 23 2018 11:10 PM
i am creating an excel file generate on button click.but after button click their is no display on popup box.
i  think jquery file conflict..but their is no jquery file is calling or adding.
 this is my code ..
 
protected void btnGenerate_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
gvd_details.DataSource = ex.Getadmindtals(name.SelectedValue);
gvd_details.DataBind();
GridView gv = new GridView();
gv.DataSource = gvd_details.DataSource;
gv.DataBind();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Details.xls");
string path = Server.MapPath("files\\");
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition", "attachment;filename=Details.xls");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gv.RenderControl(hw);
Response.Output.Write(sw.ToString());
Response.End();
}
 
plz help me..!! thnkx in adv.. 

Answers (4)