List binding object <> to Crystal Report

I have a class that contains several properties, including an object that is a List <> children object.

A simple example:

  public class LineItem { public string Name { get; set; } public decimal Amount { get; set; } } public class Invoice { public string Name { get; set; } public DateTime CreatedDate { get; set; } public List<LineItem> LineItems { get; set; } public Invoice() { ... } } 

I'm trying to associate this object (invoice in the example) with Crystal Report (using the Crystal Reports VS2008 report designer), and while I get simple properties (Name, CreatedDate) that will be displayed in the field explorer, the child collection isn’t, I tried to use ArrayList (as suggested ( How to use strongly typed lists like datasoruce for Crystal Reports ), but this did not work.

+6
source share
1 answer

After a bit of searching and experimentation, I was unsuccessful in trying to associate a report with a custom object containing a child collection. Instead of using the .Net object, I developed a report using XSD shema and at runtime generated an XML file and set the expense report data source to a DataSet, which I built using the .ReadXML method.

 var exportData = new XDocument(....); var dataSet = new System.Data.DataSet(); dataSet.ReadXml(exportData.CreateReader()); var report = new ReportDocument(); report.Load("..."); report.SetDataSource(data); 
+1
source

All Articles