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

Parameters in Sub Reports

5 Answers 248 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 21 May 2009, 02:29 PM
Hi, if I have a subreport which has the same fields as the master report that accepts 3 parameters but a different final parameter for the stored proc, can I access the main reports ReportParameters in a seperate Needdatasource event for the subreport, and then change the final parameter to whatever I want ?

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 21 May 2009, 04:28 PM
Hi Pete,

Every report has a NeedDataSource event. When this report is used for a subreport, this event can be invoked in the report itself or in the master report:
  1. Using the NeedDataSource event of the SubReport item. This method is appropriate in the case child report is shared between more than one master reports. The child report DataSource should be null, thus signaling the reporting engine to raise NeedDataSource event. Most probably the event handler will reside 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;
    ParentObj master = (ParentObj)subReportItem.DataObject.RawData;
    subReportItem.InnerReport.DataSource = master.ChildObj;
  2. Using the NeedDataSource event for the Child report. Again the child report DataSource property should be null. The handler looks like:

    Telerik.Reporting.Processing.Report report= sender as Telerik.Reporting.Processing.Report;
    Telerik.Reporting.Processing.SubReport subReportItem = report.Parent as Telerik.Reporting.Processing.SubReport;
    ParentObj master = (ParentObj)subReportItem.DataObject.RawData;
    report.DataSource = master.ChildObj; 
So if you use the first approach you would be able to access the master report parameters easily.
All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pete
Top achievements
Rank 1
answered on 22 May 2009, 07:28 AM
Thanks a lot Steve, I'll give this a go and let you know.

Pete.
0
Pete
Top achievements
Rank 1
answered on 22 May 2009, 08:16 AM
Hi Steve, firstly thanks again for the swift response, but I still can't get this to display the subreport with errors. I've used subreports many time before but never where I need to access the master reports reportparameters to fill the subreport from a stored proc, can you post a quick example showing a basic master report with a subreport showing this parameters problem on the Adventureworks database ?

Thanks in advance,

Pete.
0
Accepted
Steve
Telerik team
answered on 22 May 2009, 09:27 AM
Hello Pete,

I've used the example from this KB article to show you how to achieve this - modified project is attached.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pete
Top achievements
Rank 1
answered on 22 May 2009, 10:18 AM
Thanks a lot for all your help Steve, this is exactly what I needed.

Pete.
Tags
General Discussions
Asked by
Pete
Top achievements
Rank 1
Answers by
Steve
Telerik team
Pete
Top achievements
Rank 1
Share this question
or