Hi
I'm developing an WPF app that imports trdx file, serializes to a report object, set an ObjectDataSource and generate (using RenderReport method) to pptx file.
The trdx file contains a subreport with the same DataSource but different DataMember. The DataMember of the subreport get an input from the a report parameter (=Parameters.Param1.Value). The subreport parameter filled by the main report (Param1 =Fields.Id).
For example, for each order in the report, the subreport get its ID as parameter and returns all its order details.
In the generated report (pptx) I see all the reports data but the subreport data is empty. How should I set the DataSource, DataMember and Paramerters of the subreport correctly?
Thanks
Michal
4 Answers, 1 is accepted

Hi Neli,
I found the issue.. in BindDataToSubReports i should keep the subreport parameters before i override the report source
var temp = subReport.Parameters;
subReport.ReportSource = instanceSubReport;
subReport.Parameters.AddRange(temp);
this is the right way to do it?
Thanks
Michal
Hello Michal,
Actually, in the code, I noticed that you are using this piece of code:
var tempDataSource = (ObjectDataSource)tempReport.DataSource;
var tempParameters = tempDataSource.Parameters;
foreach (var parameter in tempParameters)
{
objectDataSource.Parameters.Add(parameter);
}
tempReport.DataSource = objectDataSource;
var instanceSubReport = new InstanceReportSource() {ReportDocument = tempReport};
subReport.ReportSource = instanceSubReport;
I made some changes in order to run the application, however, I got the following output. I tried to debug the application, but it seemed that the BindDataToSubReports method was not called. Can you please let me know what's the outcome on your end?
Sorry for the delay.
The attached sln does not include the code i worte in my last comment (i found it after i zipped the sln).
BindDataToSubReports method called in GenerateReport (MainWindow.xaml.cs line 91) only if your template (.trdx) contains sub report item.
Michal
Indeed, the code sets the subreport ObjectDataSource parameter value to '=Parameters.ID.Value', hence it expects a valid Report Parameter value for the SubReport > ReportSource. However, the InstanceReportSoruce created in the code that overrides the original UriDataSource doesn't provide such a value, and there is no default value in the subreport. For that reason, the subreport renders empty.
Here is the single line I suggest adding to the method BindDataToSubReports:
protected void BindDataToSubReports(ObjectDataSource objectDataSource, SubReport subReport)
{
...
var instanceSubReport = new InstanceReportSource() {ReportDocument = tempReport};
instanceSubReport.Parameters.AddRange(subReport.ReportSource.Parameters);
subReport.ReportSource = instanceSubReport;
}
}
Hi Michal,
Generally, the subreport DataSource should be set to an ObjectDataSource with the corresponding DataSource and DataMember. The ObjectDataSource parameter of the subreport should be set to the subreport parameter that is received from the main report with the SubReport > ReportSource. This may be done inside the subreport definition, for example, in its TRDX file.
If the subreport DataSource should be set dynamically, like the main report one, then you must deserialize the subreport, set its DataSource, and pass the subreport instance wrapped in an InstanceReportSource to the main report SubReport > ReportSource.
Regards,
Todor
Progress Telerik

Hi Todor,
Thank you for the reply.
I think this is exact what I did but its not working.
I attached my code.
Thanks
Michal
Hi Michal,
I am sorry to hear that the problem is not resolved yet. Can you please put some breakpoints and try to debug the code? Please, check which part does not work- is it setting the DataMember parameter value or assigning the datasource? It will help us a lot if you can send us a sample runnable application that reproduces the issue.

Hi Neli
I Attached the .sln file and the .tdrx files that I used
Thanks
Michal
Hi Michal,
Thank you for the provided project. I inspected it, changed some of the paths, but for some, reason, I am afraid that I was not able to run it. Can you please confirm that it works on your end? Maybe you can send me a video that demonstrates the issue. As I mentioned, you can try to debug, for example, you can put a breakpoint in the BindDataToSubReports method and what actually is returned from it.