How to bind the DataSource of a SubReport in the designer

Thread is closed for posting
5 posts, 0 answers
  1. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 03 Jan 2014 Link to this post

    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
  2. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 07 Jan 2014 Link to this post

    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.

  3. DevCraft banner
  4. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 20 Jan 2014 Link to this post

    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
  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 22 Jan 2014 Link to this post

    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.

  6. Patrick
    Patrick avatar
    372 posts
    Member since:
    Aug 2012

    Posted 23 Jan 2014 Link to this post

    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
Back to Top
DevCraft banner