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!!
Hello,
It is very hard to debug the issue in public forums, however I do have several suggestions that might help:
1) For templated columns and file exports - This may be logical to some point, since templates can contain anything including complex server-side controls, so maybe the exported cannot be that clever to export that.
I have a suggestion though - for exporting data, you can create a new datasource with one extra column / field that you can construct with code and could be what the templated column showed (or a simplified text version of it, if it contains server controls)
2) Another suggestion - can you move setting the DownLoadName property before doing the actual Export
3) Are you using any sort of AJAX enablers like WebAsyncRefreshPanel and/or UpdatePanel? File exports are not compatible with these.
4) Do you have any HttpHandlers / Modules in your website, like URL Redirects, ZIP Compressions modules, etc - these may interfere with the download in some way.
5) Can you use an HTTP monitoring tool like Fiddler or FireBug for FireFox to see what the actual output from the server is - this may provide additional clues.
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?
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.
I find that if you remove all styling prior to export you run into fewer jscript errors. Apply styling in codebehind before export.
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.