Today just wanted to share about Calling SSIS Subreport from Main report as well as Query pasrameters from Main Report to Subreport.
1)Create a Master Report sysMainRptTreatmentProviderMonthlyReport.rdlc and link dataset.xsd file to report by selecting View-->ReportData
2)Now create the subreport what you want to show as part of main report. Creation of subreport is just similar to main report.
I named subreport with sysSubRptTreatmentProviderMonthlyReport.rdlc and links XSD file.I want to pass RID number from Mainreport to subreport to show all monthly information of each and every RID dynamically.
3)After Creating SubReport Add SubReport control to Main Report by dragging and dropping. You can find Subreport control under "SubReport Items" in Toolbox. Name Subreport control exactly how you named subreport rdlc(No File extension required)
4)Now add the query parameter what you want to pass from Main Report. Here I'm Passing CaseID as a paramter. I added this parameter to Subreport Report Data Parameters and also added to Subreport control (what was dragged on Main report) by going to Subreport properties-->parameters. You can see in parameters section ADD button to add parameters. Add parameter CaseID here(Note: Paramater name should be same as what you added at Subreport Report Data Parameters .
First pic shows adding Subreport Report Data Parameters to sysSubRptTreatmentProviderMonthlyReport.rdlc
Second one shows adding paramter to Subreport Control as I explained above.
5)In your coding you have to use subreport handler in order to call subreport
AddHandler SysRptViewer.LocalReport.SubreportProcessing, AddressOf SysRptViewer_SubreportProcessing
5)Before atarting coding you have to add ObjectDataSource to reportViewer
Public Sub SysRptViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
//your code goes here
end sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SysRptViewer.ProcessingMode =ProcessingMode.Local
If (Request("ReportName").Equals("sysMainRptTreatmentProviderMonthlyReport.rdlc")) Then
SysRptViewer.LocalReport.ReportPath = "sysMainRptTreatmentProviderMonthlyReport.rdlc"reportDS = New ReportDataSource("oDsTreatmentProvMainMonthlyReport")
AddHandler SysRptViewer.LocalReport.SubreportProcessing, AddressOf SysRptViewer_SubreportProcessing SysRptViewer.LocalReport.DataSources.Add(reportDS)
SysRptViewer.LocalReport.Refresh() Response.CacheControl = "no- Cache"
Response.Expires = -1
End Sub
Passing Parameters in Handler
Public Sub SysRptViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
oDsTreatmentProvSubMonthlyReport.SelectParameters("CaseID") = New Parameter("CaseID", DbType.Int32, e.Parameters.Item(0).Values(0))
e.DataSources.Add(New ReportDataSource("dsTreatmentProvSubMonthlyReport", "oDsTreatmentProvSubMonthlyReport"))
End If
1)Create a Master Report sysMainRptTreatmentProviderMonthlyReport.rdlc and link dataset.xsd file to report by selecting View-->ReportData
2)Now create the subreport what you want to show as part of main report. Creation of subreport is just similar to main report.
I named subreport with sysSubRptTreatmentProviderMonthlyReport.rdlc and links XSD file.I want to pass RID number from Mainreport to subreport to show all monthly information of each and every RID dynamically.
3)After Creating SubReport Add SubReport control to Main Report by dragging and dropping. You can find Subreport control under "SubReport Items" in Toolbox. Name Subreport control exactly how you named subreport rdlc(No File extension required)
4)Now add the query parameter what you want to pass from Main Report. Here I'm Passing CaseID as a paramter. I added this parameter to Subreport Report Data Parameters and also added to Subreport control (what was dragged on Main report) by going to Subreport properties-->parameters. You can see in parameters section ADD button to add parameters. Add parameter CaseID here(Note: Paramater name should be same as what you added at Subreport Report Data Parameters .
First pic shows adding Subreport Report Data Parameters to sysSubRptTreatmentProviderMonthlyReport.rdlc
Second one shows adding paramter to Subreport Control as I explained above.
5)In your coding you have to use subreport handler in order to call subreport
AddHandler SysRptViewer.LocalReport.SubreportProcessing, AddressOf SysRptViewer_SubreportProcessing
5)Before atarting coding you have to add ObjectDataSource to reportViewer
Public Sub SysRptViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
//your code goes here
end sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SysRptViewer.ProcessingMode =ProcessingMode.Local
If (Request("ReportName").Equals("sysMainRptTreatmentProviderMonthlyReport.rdlc")) Then
SysRptViewer.LocalReport.ReportPath = "sysMainRptTreatmentProviderMonthlyReport.rdlc"reportDS = New ReportDataSource("oDsTreatmentProvMainMonthlyReport")
AddHandler SysRptViewer.LocalReport.SubreportProcessing, AddressOf SysRptViewer_SubreportProcessing SysRptViewer.LocalReport.DataSources.Add(reportDS)
SysRptViewer.LocalReport.Refresh() Response.CacheControl = "no- Cache"
Response.Expires = -1
End Sub
Passing Parameters in Handler
Public Sub SysRptViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
oDsTreatmentProvSubMonthlyReport.SelectParameters("CaseID") = New Parameter("CaseID", DbType.Int32, e.Parameters.Item(0).Values(0))
e.DataSources.Add(New ReportDataSource("dsTreatmentProvSubMonthlyReport", "oDsTreatmentProvSubMonthlyReport"))
End If