I'm attempting to export data from a datagrid. I'm successful at exporting it in xls, doc, html types - but csv and pdf are giving me a headache.
The code I'm using isn't anything fancy:
Response.ContentType="application/pdf";
Response.AddHeader("content-disposition","fileattachment;filename=whatever.pdf ");
Response.Write(oStringWriter.ToString());
Response.End();
break;
I can save the pdf when prompted - but when I try to open it, it says it's corrupt or not a real pdf. Same code above for XML as well, but that just makes an xml file of my entire aspx webpage..not the actual data from my datagrid.
Any suggestions on pdf and xml exporting from datagrids?
Thanks in advance.