// set the content type = "Application / VND.ms-Excel"; // Remove the charset from the content-type header. Response.charset = ""; // Turn Off the view stat. this.EnableViewState = false; StringWriter stringWriter = new StringWriter (); HtmlTextWriter htmlTextWriter = new HtmlTextWriter (stringWriter); // Get the HTML for the control entitiesGrid.RenderControl (htmlTextWriter);. // Write the HTML back to the browser Response. .Write (StringWriter.toString ()); // end the response. Response.end ();