Can't render Gridview
- From: "ad" <flying@xxxxxxxxxxxxxxx>
- Date: Sun, 7 May 2006 08:47:50 +0800
I use the codes below to render a Gridview to Excel.
But it fail with
RegisterForEventValidation can just be call in Render()
But if myGrid is a DataGrid, it run well.
How can I render a GridView to Excel?
----------------------------------------------------------------------------------------
Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
.
- Follow-Ups:
- Re: Can't render Gridview
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Can't render Gridview
- Prev by Date: Re: scope of singleton static refs in ASP.NET 2.0
- Next by Date: FileSystemWatcher WinXP versus Win2003
- Previous by thread: C# and .NET hosting with Help panel?
- Next by thread: Re: Can't render Gridview
- Index(es):
Relevant Pages
|