I am not sure why this is happening, but it ONLY happens when exporting to Excel. I have this same export functionality on other pages that work fine, for some reason this page doesn't like it and I am not sure why.
I specify the file name and format on the grid itself and then simply have these buttons:
When I click CSV or WORD it works fine. When i click Excel Export I get:
The RegisterRequiresViewStateEncryption() method needs to be called before or during Page_PreRender.
I specify the file name and format on the grid itself and then simply have these buttons:
| <asp:ImageButton ID="btn_ExportCSV" runat="server" |
| OnClick="btn_ExportCSV_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_csv.jpg" /> |
| <asp:ImageButton ID="btn_ExportEXCEL" runat="server" |
| OnClick="btn_ExportEXCEL_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_excel.jpg" /> |
| <asp:ImageButton ID="btn_ExportWORD" runat="server" |
| OnClick="btn_ExportWORD_Click" BorderColor="#F0A54E" |
| BorderStyle="Ridge" |
| ImageUrl="~/images/export_word.jpg" /> |
| Protected Sub btn_ExportEXCEL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportEXCEL.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToExcel() |
| End Sub |
| Protected Sub btn_ExportWORD_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportWORD.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToWord() |
| End Sub |
| Protected Sub btn_ExportCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_ExportCSV.Click |
| ConfigureExport() |
| grid_applications.MasterTableView.ExportToCSV() |
| End Sub |
| Public Sub ConfigureExport() |
| For x = 2 To 22 'display only columns I want |
| grid_applications.MasterTableView.Columns(x).Visible = True |
| Next |
| End Sub |
When I click CSV or WORD it works fine. When i click Excel Export I get: