I have the subreport inside a list and I want to send items from the list's data source to this subreport. I added binding ReportSource.DataSource=Field.Group to my subreport and put this subreport into a panel inside the list.
What's my next step? How can I access this data (Field.Group) within my subreport and display it?
Regards,
Alex.
6 Answers, 1 is accepted
If the binding is successful, then inside the sub-report you use the fields as normal. Fields.FieldName. If for example your group has properties: GroupName and GroupNumber, then you can call them by Fields.GruopName and Fields.GroupNumber.
For reference I have attached a sample project showing the usage of sub-reports and data-binding.
Elian
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
How can I accomplish the datasouce binding using Q2 2012?
Because this clearly doesn't work anymore:
this
.subReport1.Bindings.Add(
new
Telerik.Reporting.Binding(
"ReportSource.DataSource"
,
"=ReportItem.DataObject.Departments"
));
Tomas
Since the introduction of the new Report Sources things have changed a bit.
In your case, one option to get the same result would be to move the binding from the main report, to the detailed report. Since the sub-report is a child of the main report it can access it's elements (including the data-elements). For example this binding placed in the detailed report, would have the same output.
this
.Bindings.Add(
new
Telerik.Reporting.Binding(
"DataSource"
,
"=ReportItem.Parent.DataObject.Departments"
));
public
static
ReportSource GetReportSource(
object
dataObject)
{
var report =
new
DetailedReport();
report.DataSource = dataObject;
return
new
InstanceReportSource { ReportDocument = report };
}
this
.subReport1.Bindings.Add(
new
Telerik.Reporting.Binding(
"ReportSource"
,
"= GetReportSource(ReportItem.DataObject)"
));
Regards,
Elian
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
Tomas
REALLY struggling with this and having spent a day reading various posts, links to dead non functioning help pages and the like, conclude your documentation is very weak on the subject.
In CodeBehind in the master report we have a sub report and want to assign it to a data table that is part of a 3 table set. I have sub reports setup for each table, and corresponding NeedDataSource handlers in the main report code behind, but only the first NeedDataSource fires.
I read somewhere that if the goal is to have multiple sub reports, then each part of the report needs to have its own NeedsdataSource. Unfortunately, only the main report's NeedDataSource event fires. The sub report NeedDataSource events never fire.
ANY help appreciated. Judging by all the posts, this is an area that needs some work.
As documented here (Using the NeedDataSource event to connect data) NeedDataSource of a Data Item (SubReport in your case) is only fired if it still has no data source attached. Have you double checked that the reports that you specify as SubReports do not have DataSource property set?
Regards,
Steve
the Telerik team
HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!