I have a grid that contains 3 bands, and a series of templated columns that contain a control.
I am having trouble exporting this grid to Excel and I can't quite figure out why.
The event handler for the Export button I have on the page does the following:
ExcelExporter.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.Download
<sets up some general formatting and titles on the first few rows>
ExcelExporter.ExcelStartRow = 6
ExcelExporter.Export(SGViewGrid, excelWorkBook)
ExcelExporter.DownloadName = "Filename.xls"
Initially I had been also doing a Response.BinaryWrite and Response.End but due to the errors I had been encountering I have commented out everything after the ExcelExporter.DownloadName to assist in troubleshooting. The error I am recieving is the following:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.Details: Error parsing near 'ࡱ'.
I am assuming that I'm getting this error due to the controls in the templated columns, but I need to be able to export this grid to excel - does anyone know what I need to do to fix this?
Thanks!!
That wouldn't have resolved the issue in this case - if the export isn't compatible with the update panel then it wouldn't matter whether there was styling applied to the grid or not. The only way around it in this case, as far as I can see, is to use the trigger.
I find that if you remove all styling prior to export you run into fewer jscript errors. Apply styling in codebehind before export.
Alright... I got it to work, finally! Thanks for your help :)
What I had initially was an UpdatePanel that contained a WebPanel - the button (along with the grid) had to be contained within the WebPanel. I tried to put a trigger on the UpdatePanel for that button, but it wasn't happy with that either. So, in the end, I had to put a second UpdatePanel into my WebPanel - all that it contains is the button - I put a trigger on the embedded UpdatePanel for the button that triggers a full postback (which really sucks btw but if I have no other choice then so be it):
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="ResultsUpdatePanel" ChildrenAsTriggers="false"> <ContentTemplate> <igmisc:WebPanel ID="ResultPanel" runat="server" BorderColor="#3399FF" BorderStyle="Solid" BorderWidth="1px" Width="640px" ExpandEffect="None"> <Header Text="Results" TextAlignment="Left"> <ExpandedAppearance> <Styles BackColor="#507CD1" Font-Bold="True" ForeColor="White"> <Padding Bottom="3px" Left="3px" Right="3px" Top="3px" /> </Styles> </ExpandedAppearance> </Header> <Template> < my web grid control goes here > <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpdatePanel1" ChildrenAsTriggers="false"> <ContentTemplate> <asp:Button ID="ExportButton" runat="server" Text="Export" Visible="true" /> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="ExportButton" /> </Triggers> </asp:UpdatePanel> </Template> </igmisc:WebPanel> </ContentTemplate> </asp:UpdatePanel>
alannaw said:Is there a reason why the File Exports aren't compatible with WebAsynchRefreshPanel and UpdatePanels?
To make this work, you need to tell the panel to not process your button click using AJAX. For WARP, you can add the button's client-side ID to the WARP's TriggerPostBackIDs property (which, if you do this at runtime, is best done using the AddTriggerPostBack() method). I'm not sure how to accomplish the same thing using UpdatePanel.
Thanks for your suggestions.
Is there a reason why the File Exports aren't compatible with WebAsynchRefreshPanel and UpdatePanels? It seems like this should be required functionality seeing as I have found quite a few posts with people having the same issue.
I have determined that my issue is the fact that the grid is contained within an UpdatePanel - the export is fired off by a button, which is also in the UpdatePanel. However, they both need to be there and the export needs to work. I can get the export to work just fine if I move the button out of the panel, but again, it needs to be there.
Are there any work-arounds that would allow for me to keep the button in the panel as well?