0

Hi,

ASP.Net does not shows Save As dialogue box while converting Datgrid into Excel/Pdf.
My code has no errors. It Doesn't do anything.

I am using this code:

Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=Sample.xls");
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);

dg.DataSource = dmpset;
dg.DataBind();
dg.RenderControl(htw);


//GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();

Please anyone knows helps me.

Thanks in advance...

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by sanjanaa
0

It might be occured due to IE browser setting.

Change browser settings as mentioned below:
--Click Tools | Internet Options
--Go to the Security tab, then click the Custom Level button.
--Under the Downloads section of the list, look for Automatic prompting for file downloads and click Enable.
--Click OK.

0

Hi Ramesh, Thanks for your reply. I have tested the same code in another aspx file within the same solution explorer. That works fine and downloads files. But it doesn't download in a particular aspx only...

please help for my problem...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.