Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Response.Clear();
       Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xls", fileName));
       Response.Charset = "";
       Response.Cache.SetCacheability(HttpCacheability.NoCache);
       Response.ContentType = "application/vnd.xls";
       StringWriter stringWrite = new StringWriter();
       HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
       grdGridView.RenderControl(htmlWrite);
       Response.Write(stringWrite.ToString());
       Response.Flush();
       Response.End();


Iam using above code to export excel..but there is a error at line

grdGridView.RenderControl(htmlWrite); 


says http exception was unhandled by user code
please help me with this
Posted
Updated 19-May-10 2:30am
v3

1 solution

Put a try/catch block around it and ru it under the debugger to see exactly what the error is. At that point, you should be able to figure it out.
 
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