Click here to Skip to main content
15,917,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Could any one please help me how to export the data from GridView to Excel with out using the below code.

C#
public void ExportFile(string FileName)
       {
           string name = "Test File";
           Response.AppendHeader("content-disposition", "attachment; filename=" + name);
           Response.ContentType = "application/vnd.ms-excel";
           Response.WriteFile(FileName);
           Response.End();
       }


The problem is if we use the above code, after exporting the data to excel Remaining events are not working in the same page(Buttons- Event firing is not happening).


Please advice me how to resolve this.

Thanks
venkat.
Posted
Comments
pramod.hegde 28-Aug-12 8:37am    
Refer this thread
http://www.codeproject.com/Tips/366446/Export-GridView-Data-to-Excel-using-OpenXml
ZurdoDev 29-Aug-12 8:36am    
You can call the Export from an asynchornous webservice using jQuery.ajax and then at least have some control over it.

1 solution

The only way to download a file is as a single request. As such, the file is all that you want to serve, and you have to end the response. If you want to do any other operations, you should do them before serving the file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900