VS2008, ASP.net 3.5
In my project I've created an enhancedwebgrid class that implements ultrawebgrid, it adds a handful of properties, and overrides render and on databound, the render override just adds a string "Found X results" and the databound one adds a default column.
The problem arises when I try to export using the ultrawebgrid.documentexporter, I receive a nullreferenceexception.
Here's an image of the exceptiion
The text of the stack trace is...
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 CustomWebGrid.ButtonExport_Click(Object sender, EventArgs e) in CustomWebGrid.ascx.cs:line 184 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The code in question is..
var exporter = new UltraWebGridDocumentExporter(); exporter.Format = FileFormat.PlainText; exporter.TargetPaperOrientation = PageOrientation.Landscape; exporter.DownloadName = "report.txt"; exporter.ExportMode = Infragistics.WebUI.UltraWebGrid.Exporter.ExportMode.InBrowser; exporter.DataExportMode = DataExportMode.DataInGridOnly; exporter.Export((UltraWebGrid)EnhancedWebGrid1);
I've tried leaving off the DataExportMode, using PDF and XPS formats, although that made no difference.
I also tried on the fly creating a new UltraWebGrid (the base class mine implements) and setting it's datasourceID to the dataobject I use for the other webgrid and calling export on that to see if I can get anything to appear, I receive the same error, as well as for a new Webgrid with no datasource specified.
I've debugged and verified that the webgrid I'm sending in has data, it's not being lost due to postbacks or anything like that, I'm open to suggestions/ideas.
Lonely... so lonely...
One last try.
Yes, most probably the exporter needs to be added to the Page Control Tree in order to operate correctly (find grid instances, etc, etc). If you are creating this dynamically, you can probably create an empty placeholder, e.g.
<asp:placeholder runat="server" ID="PlaceHolder1" ... />
and then add it to the controls collection of the placeholder at runtime:
PlaceHolder1.Controls.Add(exporterInstance);
I was getting the same thing if I created a UltraWebGridDocumentExporter on the fly. If I added it to the .aspx page it workd fine.