I'm having trouble getting a PDF export to work when I put my grid into a User Control. The same code works fine when it lives in its own aspx page. Are there any known issues with this?
- All the User controls are inside a WebAsyncRefreshPanel:
<igMisc:WebAsyncRefreshPanel ID="webPanel" InitializePanel="webPanel_InitializePanel" runat="server"> <ADV:AvailSearches ID="AdvAvailSearches" runat="server" EnableViewState="true" /><br /> <asp:Placeholder ID="AdvCriteriaContainer" runat="server" EnableViewState="true" /> <br /> <asp:Placeholder ID="AdvResultsContainer" runat="server" EnableViewState="true" /></igMisc:WebAsyncRefreshPanel>
In the User Control which I load into AdvResultsContainer, I have:
In the aspx page, I have:
<igtbldocexp:UltraWebGridDocumentExporter ID="UltraWebGridDocumentExporter1" runat="server" /> <igtblexp:UltraWebGridExcelExporter ID="UltraWebGridExcelExporter1" runat="server" />In the code behind, I have this method being called by an event tied to a LinkButton:
protected void PDFExport_Click(object sender, EventArgs e){ try { UltraWebGridDocumentExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.Exporter.ExportMode.Download; UltraWebGridDocumentExporter1.Format = Infragistics.Documents.Report.FileFormat.PDF; UltraWebGridDocumentExporter1.DataExportMode = Infragistics.WebUI.UltraWebGrid.DocumentExport.DataExportMode.DataInGridOnly; UltraWebGridDocumentExporter1.Export(mygrid); } catch (Exception ex) { throw ex; }}When I debug this, it goes to Export(mygrid) and throws this Exception (as if it lost the handle to the object???)
System.NullReferenceException was caught Message="Object reference not set to an instance of an object." Source="Infragistics2.WebUI.UltraWebGrid.DocumentExport.v8.1" StackTrace: at Infragistics.WebUI.UltraWebGrid.DocumentExport.CssClassCollection.AddStyles(UltraWebGrid grid) at Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter.RenderDocument() at Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter.Export() at Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter.Export(UltraWebGrid grid, ISection section) at Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter.Export(UltraWebGrid grid, Report report) at Infragistics.WebUI.UltraWebGrid.DocumentExport.UltraWebGridDocumentExporter.Export(UltraWebGrid grid) at GPMS.Dashboard.UserControls.SalesDetail_Results.PDFExport_Click(Object sender, EventArgs e) in C:\GPMS\GPMS\Dashboard\UserControls\SalesDetail_Results.ascx.cs:line 293
Line 293 is the call to Export()
From your setup it appears that you are loading the grid instance dynamically in the user controls with AJAX, while the export takes place in a postback event handler. My feeling is that in the postback event handler the grid is not available on the page (you will need to expicitly add it to the placeholder/or load user controls containing the grid explicitly) before calling export to PDF.