Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,

i want to downlaod the data which show in my gridview can any one guide me??
C#
 string attachment = "attachment; filename=rates.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView1.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();  


i am using this code for download button but this code download only the current page means we have 3 page in gridview this code download only that page which is show on gridview. help me friends
Posted
Updated 20-Jul-11 19:15pm
v2
Comments
janwel 21-Jul-11 1:15am    
why do you have to use gridview? why not use crystal reports?
guptaadeepak 21-Jul-11 4:14am    
my database is mysql not mssql and i dont know how to use crystal reports use with mysql.

1 solution

 
Share this answer
 
Comments
guptaadeepak 21-Jul-11 4:22am    
hello friend i m view your link infact i want download data which on paging when i am click on export button but when i am click on export button then only current page is download what will i do??
Mohammad A Rahman 21-Jul-11 5:21am    
Please visit this link, http://geekswithblogs.net/azamsharp/archive/2006/01/09/65368.aspx it will help you to resolve the paging problem when export to excel. The code you need to look at is GridView1.AllowPaging = false; :)

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