简体   繁体   中英

RDLC report with subreport from parent dataset?

So, I am trying to figure out how to do the following:

Imagine I have a collection of customers. It contains the following properties:

  • CustomerName
  • AccountNumber
  • TotalAmount

Now for each customer, it has a collection of invoices. Each invoice contains the following properties:

  • InvoiceNumber
  • InvoiceDate
  • AmountDue
  • Payment

I have the data retrieved from a service and stored locally. So, a collection of customers and each customer has invoices. So far so good? Pretty simple to understand!

Now, I have an RDLC and I have got it to display the collection of customers by adding the dataset, being a model from the codebase. That's all fine, binding and working and displaying the data I need.

What I am having difficulty now is how to display the list of invoices FOR THAT RECORD (the current customer).

Any ideas how to do this? I do not even know how to begin or what to use so please do not say "What have you tried?" - I do not even know where to begin, thus that question is invalid! :-)

Currently on the form I have a tablix. The tablix points to the Customer dataset (DataSet1) and the fields are added to display the property values from that dataset.

Next I need it so that either within the tablix OR something else, to take the invoices for that record and render it (with header)

I am stuck and would appreciate guidance in the right direction.

Code to render the report viewer (not that this matters at all at this point - it's the RDLC I am having difficult with):

public void RunReport<T>(List<T> reportData, List<ReportParameter> parameters, string reportLayout)
        {
            var viewer = ReportViewerHost.Child as Microsoft.Reporting.WinForms.ReportViewer;
            viewer.Reset();
            viewer.ProcessingMode = ProcessingMode.Local;
            viewer.LocalReport.ReportEmbeddedResource = "PlayPen.ReportLayouts." + reportLayout + ".rdlc";
            viewer.LocalReport.SetParameters(parameters);
            viewer.SetDisplayMode(DisplayMode.PrintLayout);
            viewer.ZoomMode = ZoomMode.PageWidth;
            viewer.LocalReport.DataSources.Clear();
            viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", reportData));
            viewer.RefreshReport();
        }

Calling method:

this.reportViewer.RunReport(this.OutstandingInvoices, new List<ReportParameters>(), "OutstandingInvoices");

Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM