Exporting to Excel directly from ObjectDataSource?
- From: ASF <roy.anderson@xxxxxxxxx>
- Date: Fri, 20 Jun 2008 12:40:27 -0700 (PDT)
Hey all,
I have a gridview with an objectdatasource. I've been using the below
code to export to excel:
gvITV.AllowSorting = False
gvITV.DataBind()
Dim tw As New IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Dim frm As HtmlForm = New HtmlForm()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=export.xls")
Response.Charset = ""
EnableViewState = False
Controls.Add(frm)
frm.Controls.Add(gvITV)
frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
gvITV.AllowSorting = True
gvITV.DataBind()
However, I dislike that I have to pull from the Gridview at all. I
should be able to skip the gridview binding and pull directly from the
objectdatasource, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
.
- Follow-Ups:
- Re: Exporting to Excel directly from ObjectDataSource?
- From: Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
- Re: Exporting to Excel directly from ObjectDataSource?
- Prev by Date: Re: asp to asp.net
- Next by Date: Re: Asp.net 2.0 / Apache 2.2.6 / Ajax
- Previous by thread: Optimizing 2.0 Wizard performance?
- Next by thread: Re: Exporting to Excel directly from ObjectDataSource?
- Index(es):
Relevant Pages
|