A
ASF
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?
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?