This is a migrated thread and some comments may be shown as answers.

How to bind the DataSource of a SubReport in the designer

4 Answers 743 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 2
Veteran
Iron
Patrick asked on 03 Jan 2014, 10:05 AM
Hello,
I have a report that contains a SubReport. The sub report ReportSource is set to a type name.
What I would like to define in the designer is that the DataSource of the sub report is the same as the DataSource of the main report. How can I do this?
Patrick

4 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 07 Jan 2014, 02:34 PM
Hi Patrick,

Open the sub report designer and use the following binding to the report's DataSource property:
Property path: DataSource
Expression: =ReportItem.DataObject

Thus when added in a SubReport item, the report will get its data from the DataObject of the SubReport item. Using the Parent key word you can go up the hierarchy of elements and get the whole report data e.g. =ReportItem.Parent.Parent.Parent.DataObject for a sub report placed in a Detail section of report without groupings.

I hope this helps you.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Patrick
Top achievements
Rank 2
Veteran
Iron
answered on 20 Jan 2014, 11:00 AM
Hi Stef,
I tried to add this binding but, when generating the report, I have the following error message:
An error has occurred while processing DetailSection 'detail':
Bindings error - Property 'DataSource' does not exist.
Patrick
0
Stef
Telerik team
answered on 22 Jan 2014, 06:59 PM
Hi Patrick,

The binding should be applied to the report that will be displayed in the SubReport item. Open it in the Report Designer, go to the Property Grid - Bindings and set its DataSource property to the expression. When you hit preview in the master report, the sub report will be loaded with data.

If you need further help, please elaborate on the reports structures.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Patrick
Top achievements
Rank 2
Veteran
Iron
answered on 23 Jan 2014, 07:33 AM
Hi Stef,
thank you for clarification: it is working now.
As I think it is a common scenario, the documentation for SubReport should be updated with this information.
Patrick
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 2
Veteran
Iron
Answers by
Stef
Telerik team
Patrick
Top achievements
Rank 2
Veteran
Iron
Share this question
or