Export--Linkbutton

m_mahesh

Member
Joined
Jun 3, 2004
Messages
5
Location
Pune
Programming Experience
1-3
Hi
i have a datagrid with a button column,button type is Linkbutton

and i'm exporting the datagrid to Excel by the following code
Dim tw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AppendHeader("ContentType", "application/octet-stream")
Response.AppendHeader("Content-Disposition", "attachment; filename=" & "abc.xls" & "")
dgOrderRate.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()

but it is giving an error like this
'DataGridLinkButton' must be placed inside a form tag with runat=server.
please help me out
i want export the grid as it is disaplaying on the webform
if i remove the linkbutton it is working fine
and the sme problem persists if i set the allowsorting=true
 
Within the <body> tag of your html you will need to place the button inside a form tag like such

<form runat="Server">
<asp:Button id="Button1" onclick="Button_Click" Runat="Server" Text="Login"></asp:Button>

</form>

The button should now work fine, if not then let us know
 
Back
Top