Hi
I have been using an UltraWebGrid and UltraWebGridDocumentExporter on a web form (ASP.Net 2.0) to export a report in PDF. To run the report I was directing my execution onto this form.
I would like to now have this functionality called from my code, without having to visit this form. So I created a .cs class and copied and pasted my code in it. Because the class does not contain any web controls, I only instantiated them in code like so:
UltraWebGrid
UltraWebGrid1 = new UltraWebGrid();
// Set the WebGrid's view type to Hierarchical
UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.
.Hierarchical;
// Bind the DataSet to the Grid
UltraWebGrid1.DataSource = incidentDataSet.Tables[0]; UltraWebGrid1.DataBind(); //Now set up the exporter UltraWebGridDocumentExporter UltraWebGridDocumentExporter1 = new UltraWebGridDocumentExporter (); UltraWebGridDocumentExporter1.TargetPaperOrientation = Infragistics.Documents.Report. PageOrientation.Landscape; UltraWebGridDocumentExporter1.TargetPaperSize = Infragistics.Documents.Report. PageSizes .A4; ............... --------------- //Export the report UltraWebGridDocumentExporter1.Export(UltraWebGrid1, s); When I call the export function on the UltraWebGridDocumentExporter, I get an error: "object reference not set to an instance of an object" Can I use the UltraWebGridDocumentExporter as I am? What can the problem be? Thanks Chris
UltraWebGrid1.DataSource = incidentDataSet.Tables[0];
UltraWebGrid1.DataBind();
//Now set up the exporter
UltraWebGridDocumentExporter1.TargetPaperOrientation = Infragistics.Documents.Report.
UltraWebGridDocumentExporter1.TargetPaperSize = Infragistics.Documents.Report.
PageSizes .A4;
...............
---------------
//Export the report UltraWebGridDocumentExporter1.Export(UltraWebGrid1, s);
//Export the report
UltraWebGridDocumentExporter1.Export(UltraWebGrid1, s);
When I call the export function on the UltraWebGridDocumentExporter, I get an error:
"object reference not set to an instance of an object"
Can I use the UltraWebGridDocumentExporter as I am? What can the problem be?
Thanks
Chris
Hi Chris,It has been some time since your post, in case you still need assistance I will be glad to help. I believe the other community members can benefit from this answer as well.In order for the UltraWebGridDocumentExporter to work, the instantiated exporter has to be added to a form's control collection. This can be done using : form1.Controls.Add(UltraWebGridDocumentExporter1);More information on how to use the exporter and an illustrative sample is available from this thread:
http://help.infragistics.com/Help/Doc/ASPNET/2010.3/CLR4.0/html/Infragistics4.WebUI.UltraWebGrid.v10.3~Infragistics.WebUI.UltraWebGrid.Exporter.UltraWebGridExporter_members.htmlPlease contact me if you have any more questions.Best Regards,Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://www.infragistics.com/support