הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Sunday, September 8, 2013 4:39 AM
Hi,
I am trying to build subreports in rdlc and I created report1 (Main Report) and report 2(Subreport) with defining parameters and other requirements as given by the example in (http://shahfaisalmuhammed.blogspot.com/2011/10/building-subreport-in-reporting.html). But that is for reporting services and not for local report processing and hence there is no code given.
My report1 and report2 have a relationship on OrderID field and can any one give me the required code and where to write them.
Thanks
All replies (3)
Sunday, September 8, 2013 4:42 PM ✅Answered
Hi,
I could resolve this but I am not sure whether the method I followed was the best way since it takes few seconds to process the sub report.
Please look into my code and suggest if any improvement that I can do to improve performance of the report generating. My main report (Report1) was based on "Order" table and subreport (Report2) was based on Orders Details table.
Thanks
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'NorthwindDataSet.Orders' table. You can move, or remove it, as needed.
'Me.OrdersTableAdapter.Fill(Me.NorthwindDataSet.Orders)
ReportViewer1.LocalReport.DataSources.Clear()
Dim adapter As NorthwindDataSetTableAdapters.OrdersTableAdapter = New NorthwindDataSetTableAdapters.OrdersTableAdapter
Dim table As NorthwindDataSet.OrdersDataTable = New NorthwindDataSet.OrdersDataTable
adapter.Fill(table)
Dim myNewDataSource As ReportDataSource = New ReportDataSource("NorthwindDataSet_Orders", CType(table, DataTable))
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(myNewDataSource)
AddHandler Me.ReportViewer1.LocalReport.SubreportProcessing, AddressOf MySubreportEventHandler
ReportViewer1.LocalReport.Refresh()
ReportViewer1.RefreshReport()
End Sub
Public Sub MySubreportEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
Dim adapter1 As NorthwindDataSet1TableAdapters.Order_DetailsTableAdapter = New NorthwindDataSet1TableAdapters.Order_DetailsTableAdapter
Dim table1 As NorthwindDataSet1.Order_DetailsDataTable = New NorthwindDataSet1.Order_DetailsDataTable
Dim OrderNo As Integer = e.Parameters(0).Values(0)
adapter1.FillByOrderNo(table1, OrderNo)
e.DataSources.Add(New ReportDataSource("NorthwindDataSet1_Order_Details", table1))
End Sub
Monday, September 9, 2013 9:09 AM
it is a good solution.
Monday, September 9, 2013 9:44 AM
Thank you Tina