Data Grid to Excel

c00lbeans

Newcomer
Joined
Jan 13, 2004
Messages
10
Hi I am trying to export data from a datagrid to excel. I am using the code specified in most tutorials for doing thi.
i.e

Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms- excel";
Response.Charset = "";
this.EnableViewState = false;
StringWriter tw= new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ResultGrid.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();

The problem is it is not doing anything, shows me a a page not found error. I am not able to figure out what is happening.
Am i missing something?Any help is appreciated.

thanks
Sam
 
Back
Top