I have a very simple gridview that i want to export to excel. I have a button that the user will click to export the gridview content to excel.
The code is pretty standard (see in code section), and i've successfully done it for many pages before. Somehow for this one, i could not get it to work. It downloads an excel file, but the sheet is empty.
The server is running IIS 6 on Windows Server 2003. Is there any server settings i need to change to make this work? My code is attached below. I also have set EnableEventValidation="fal
se" in the aspx page settings.
Hope someone can help me..Thanks!
'Export button code
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click
Dim filename As String
filename = "MMEAHistory"
Public Sub ExportToExcel(ByVal filename As String)
Response.AddHeader("content-disposition", "attachment;filename=" & filename & ".xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(sw)
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)