I am trying to export a datagrid to an excel sheet. I found this code at the following location:http://codebetter.com/blogs/darrell.norton/archive/2004/02/12/7154.aspx
' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel"
'Turn off the view state
Me.EnableViewState = False
'Remove the charset from the Content-Type header
Response.Charset = String.Empty
Dim myTextWriter As New System.IO.StringWriter
Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWrit
'Get the HTML for the control
'Write the HTML to the browser
'End the response
The problem is that I have a checkbox in my datagrid and I get the following error when I run it:
Control 'dg_disp__ctl2_cbSelect' of type 'CheckBox' must be placed inside a form tag with runat=server.
If I remove the checkbox it will export the data. Does anyone know of a way that I can export the rest of the data in the grid without exporting the checkbox? I would appreciate the help. Thank you!