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

Handle multiple datasource from code

1 Answer 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Franko Govanni
Top achievements
Rank 1
Franko Govanni asked on 23 Nov 2009, 06:36 PM
Hi:

I need to use different a Subreport datasource as the information comes from different tables in my database, but I want to do this using code and not through the wizard.

How can I do to accomplish this, or another option I suggest a package?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 24 Nov 2009, 04:23 PM
Hello Franko,

Delivering data for a child subreport can be accomplished in three ways:
  • Using report parameters and filters (done through the report designer)
  • Using the NeedDataSource event of the SubReport item
  • Using the NeedDataSource event of the Child report.
From your scarce explanation, it would seem that you aim for #2. This method is appropriate in the case child report is shared between more than one master reports and thus show different data depending on the context. The child report DataSource should be null, thus signaling the reporting engine to raise NeedDataSource event. The event handler usually resides in the Master report definition class. The handler normally looks as the next code snippet:

Telerik.Reporting.Processing.SubReport subReportItem = sender as Telerik.Reporting.Processing.SubReport;
subReportItem.InnerReport.DataSource = <your_datatable>;


Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Franko Govanni
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or