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

Subreport Datasource empty

2 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Denis
Top achievements
Rank 1
Denis asked on 04 Nov 2020, 11:43 AM

Hello,

MyMasterReport contains 3 subreport
in the report Master I have MyMasterReport.Datasource = MyModelClass

I wold like to have this:

subreport1.Datasource = MyModelClass.List1  //List1 is a property of my class MyModelClass and is a List<myObject1>
subreport2.Datasource = MyModelClass.List2  //List2 is a property of my class MyModelClass and is a List<myObject2>
subreport3.Datasource = MyModelClass.List3  //List3 is a property of my class MyModelClass and is a List<myObject3>

so, I create MyModelClass with a lot of property, one for each datasource

I send MyModelClass  to master report, and it works:

-----------------------------

MyModelClass my_datasource_master = new MyModelClass();

master_report = new Reports.MyMasterReport();
master_report.Datasource = my_datasource_master;

--------------------------

 

How can I add MyModelClass.List1 to subreport1, etc... ?

In subreport1 I have just datasource, is myObject1 (and every subreport has indipendent datasource)

My problem is to link  MyModelClass property List1 to my subreport1 datasource.

As you suggest in your post "https://www.telerik.com/forums/set-subreport-datasource-programmatically", in MyMasterReport I create binding has the follow image, but the subreport items are empty

And after the InitializeComponent() how can I do? Can I passing a List of Object as Parameters?
------------
Help me please,
Thank you

2 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 09 Nov 2020, 10:12 AM

Hi Denis,

I suspect that the issue comes from the Binding. In the report definition of the subreport report, I would suggest to test the following Binding:

Property path: DataSource 

Expression: =ReportItem.Parent.DataObject.NameOfField (for example =ReportItem.Parent.DataObject.Price)

This Binding would generally assign the Price field of the Report parent to the subreport report.

Please, find further information in How to use the ReportItem.DataObject property in expressions article.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Denis
Top achievements
Rank 1
answered on 10 Nov 2020, 09:15 AM
Thank you so much, I solved it!
Tags
General Discussions
Asked by
Denis
Top achievements
Rank 1
Answers by
Neli
Telerik team
Denis
Top achievements
Rank 1
Share this question
or