Hi there,
My scenario is this....
Report 1: Has a sqldatasource which calls a stored procedure which takes in 2 parameters.
Report 2: Has a sqldatasource which calls a different stored procedure but takes in exactly the same 2 parameters.
Report 1 contains summary information. Report 2 contains detailed information.
I need to combine the reports. Therefore my thinking is that Report 1 will be the master and Report 2 will be the sub.
My question is: how can i pass the datasource params from Report 1 (Master) to the Report 2 (Sub)?
Any help greatly appreciated.
4 Answers, 1 is accepted
I assume that you use a Master Report with a SubReport item which source is the Sub Report.
It is possible to pass the sqlDataSource parameters between the two datasources using ReportParameters. You can follow these steps:
- create two ReportParameters in the Sub Report that correspond to the two store procedure parameters
- set the Sub Report sqlDataSource parameters values to correspond to the values of the Sub Report ReportParameters
- create the same ReportParameters in the Master Report
- from SubReport item ReportSource Property choose Edit Paremeters and set the Parameter Name to the corresponding Sub Report ReportParameter, and Parameter Value to the corresponding ReportParameter (or data field value) of the Master Report
- set the values of Master sqlDataSource paremeters to correspond to the Master Report ReportParameters (and thus to the Sub Report sqlDataSource parameters)
Regards,
Todor
Progress Telerik
Thank you very much Todor - that worked.
One final question....
When we run the reports programmaticly I set the the Master Report data source and parameter value using....
Dim rep = TryCast(Activator.CreateInstance(Reflection.Assembly.Load("IFMReportLibrary").GetType("IFMReportLibrary.VINSByDriver")), Report)
TryCast(rep.DataSource, Telerik.Reporting.SqlDataSource).Parameters.RemoveAt(0)
TryCast(rep.DataSource, Telerik.Reporting.SqlDataSource).Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue)))
Which works correctly.
Now I am trying to do the same for the sub report using....
Dim sReport As Telerik.Reporting.SubReport = TryCast(rep.Items.Find("SubReport1", True)(0), Telerik.Reporting.SubReport)
'sReport.ReportSource.Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue))
TryCast(sReport.Report.DataSource, Telerik.Reporting.SqlDataSource).Parameters.RemoveAt(0)
TryCast(sReport.Report.DataSource, Telerik.Reporting.SqlDataSource).Parameters.Add(New SqlDataSourceParameter("@inspectionID", SqlDbType.Int, CInt(listInspections.SelectedValue)))
But this does not work.
Can you help?
In the provided code sample the SubReport item (sReport) is an item in the main report, and sReport.Report is actually its parent/main report.
Note that the sub report would be specified in sReport.ReportSource. This sub report should then be updated with the parameters or datasource.
I would refer you to the API of the SubReport class.
Regards,
Todor
Progress Telerik
Todor - thank you very much - the information you provided enabled me to understand where I was going wrong.
Everything now working so again thank you for your help it is much appreciated.
All the best
Geoff