faraz akram

faraz akram

  • NA
  • 129
  • 0

exporting datagrid to pdf

Dec 6 2010 11:27 AM

hi am trying to export datagrid to pdf file by using this piece of code:
string
attachment = "attachment; filename=Contacts.pdf";
Response.ClearContent();
Response.AddHeader(
"content-disposition", attachment);
Response.ContentType =
"application/pdf";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
the file save at disk very fine but when i open the file it give me the error as the file cannot be opened either it is damaged or some file sent via email..
plz advise
thanks in advance
 

Answers (5)