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...

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.

Just ignore.I replied with out seeing the above reply

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.