Hey all,
I have a gridview with an objectdatasourc e. I've been using the below
code to export to excel:
gvITV.AllowSort ing = False
gvITV.DataBind( )
Dim tw As New IO.StringWriter ()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=export.xl s")
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(gvITV)
frm.RenderContr ol(hw)
Response.Write( tw.ToString())
Response.End()
gvITV.AllowSort ing = 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
objectdatasourc e, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
I have a gridview with an objectdatasourc e. I've been using the below
code to export to excel:
gvITV.AllowSort ing = False
gvITV.DataBind( )
Dim tw As New IO.StringWriter ()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=export.xl s")
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(gvITV)
frm.RenderContr ol(hw)
Response.Write( tw.ToString())
Response.End()
gvITV.AllowSort ing = 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
objectdatasourc e, but I haven't been able to discover a way to do
this. Does anyone have any suggestions?
Comment