I am working on an application that requires several types of Crystal Reports, the βstandardβ ones that fall into the database table, update the connection string and update the report. Another type of Crystal Report is based on a regular (slightly complex) class object or POCO object.
The problem I am facing is that the report data source is based on the class we created, it has properties that are also the classes we created. When I update the report, the data in the object is updated, but the data in the objects of the child object is not updated. They remain as the values ββset when creating the report.
A bit of background, the environment is C # on VS2010 with Crystal Reports 2011.
To create a report, I created an object and populated each property with relevant data, including child objects, then I exported the object to XML and output it to a file. Then I created a new report and added a data source like "ADO.NET (XML)".
All the βtablesβ turned out to be beautiful, and I was able to create and add links, design and view the report, as usual.
When it came to runtime testing, I started with the code from this StackOverflow question:
.NET - Convert a shared collection to a DataTable
to convert the list of my objects to a DataTable and assign it as the data source for the report. As mentioned earlier, it works for the first level, but not for child properties.
I modified this code to create a new DataTable when the child property is one of our created classes, and not just a CLR data type, but now this leaves me with an empty report. This code is below:
public static class CollectionExtensions {
I think the problem is that I have a gap between how I create the report and how the data is applied at runtime when the data source is updated.
But I've never done an XML-based Crystal Report before, I'm not quite sure how to solve this. My questions to experts:
- Am I on the right track to create a report in the first place?
- Given how I create the report, can I choose the right way how I update the report?
- Is there a better way to achieve the same result? For the tiered object that is the data source for the Crystal Report XML report.