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

Setting SubReport Datasource Location

1 Answer 139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 01 Mar 2012, 04:08 PM
I have been reading threads about setting a subreport's datasource.   I am confused about where to set it programmatically.  Some threads show it being set after the Master report InitialComponent() event.  Some threads show it via the subrpt_NeedDataSource or Subrpt_ItemDatabaBinding within the parent report class file.  Others show it being set in the Subreport's class file in its NeedDataSource or Item Databinding event.

Could someone please tell me where to set the subreport datasource?

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 02 Mar 2012, 03:19 PM
Hello Dan,

It can be set in several ways but this depends entirely on your needs. In some cases one approach can provide functionality that the others can't - there is no wrong way, as long as it works correctly.
The recommended way is not to set the SubReport's DataSource from outside but let the SubReport get the data by itself, you only  pass parameters to it so it filters the data accordingly - this approach is demonstrated in our Invoice demo
If you use objects (not sqlDataSource) and you have nested collections and one SubReport is repeated many times, then you can set the data-source using Bindings
In some cases you can even access the Parent Report object from inside the SubReport to retrieve the data you need. 

All the best,
Elian
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or