K
Kathy Burke
Hi again,
I have a datagrid which uses several fields such as:
<asp:BoundColumn DataField="DateEntered" HeaderText="Date Entered"
SortExpression="DateEntered"></asp:BoundColumn>
All works ok, until I put this code in the page to allow the user save
the html table as an excel file:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=MyFileName.xls")
Response.Charset = ""
Me.EnableViewState = False
'get datagrid HTML from the control, write straight to browser
Dim objSW As New System.IO.StringWriter()
Dim objHTW As New System.Web.UI.HtmlTextWriter(objSW)
dg.RenderControl(objHTW)
Response.Write(objSW.ToString())
Response.End()
I get a global failure saying: System.Web.HttpException: Control
'dg__ctl1__ctl0' of type 'DataGridLinkButton' must be placed inside a
form tag with runat=server.
this control is the DateEntered sort column heading in the datagrid
(first control of the row).
Any clues, as always, greatly appreciated...this one is driving me a bit
nuts.
Thanks,
Kathy
I have a datagrid which uses several fields such as:
<asp:BoundColumn DataField="DateEntered" HeaderText="Date Entered"
SortExpression="DateEntered"></asp:BoundColumn>
All works ok, until I put this code in the page to allow the user save
the html table as an excel file:
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=MyFileName.xls")
Response.Charset = ""
Me.EnableViewState = False
'get datagrid HTML from the control, write straight to browser
Dim objSW As New System.IO.StringWriter()
Dim objHTW As New System.Web.UI.HtmlTextWriter(objSW)
dg.RenderControl(objHTW)
Response.Write(objSW.ToString())
Response.End()
I get a global failure saying: System.Web.HttpException: Control
'dg__ctl1__ctl0' of type 'DataGridLinkButton' must be placed inside a
form tag with runat=server.
this control is the DateEntered sort column heading in the datagrid
(first control of the row).
Any clues, as always, greatly appreciated...this one is driving me a bit
nuts.
Thanks,
Kathy