因此,我正在尝试弄清楚如何执行以下操作:
假设我有一组客户。它包含以下属性:
- 客户姓名
- 帐号
- 总金额
现在对于每个客户,它都有一组发票。每张发票包含以下属性:
- 发票编号
- 发票日期
- 应付金额
- 付款
我从服务中检索数据并存储在本地。因此,一组客户和每个客户都有发票。到目前为止,一切都很好?非常简单易懂!
现在,我有一个 RDLC,我已经通过添加数据集(来自代码库的模型)来显示客户集合。一切都很好,绑定(bind)并工作并显示我需要的数据。
我现在遇到的困难是如何显示该记录(当前客户)的发票列表。
任何想法如何做到这一点?我什至不知道如何开始或使用什么,所以请不要说“你试过什么?” - 我什至不知道从哪里开始,因此该问题无效! :-)
目前在表格上我有一个 tablix。 Tablix 指向客户数据集 (DataSet1),并添加字段以显示该数据集的属性值。
接下来我需要它,以便在 tablix 或其他东西中获取该记录的发票并呈现它(带标题)
我被卡住了,希望得到正确方向的指导。
呈现报告查看器的代码(这在这一点上并不重要——这是我遇到困难的 RDLC):
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();
}
调用方法:
this.reportViewer.RunReport(this.OutstandingInvoices, new List<ReportParameters>(), "OutstandingInvoices");
谢谢。
最佳答案
我遇到了同样的问题。我使用了一个子报表,它们之间有一个参数来绑定(bind)数据。 我使用了以下指南: https://marcelwouters.wordpress.com/2011/06/01/showing-a-report-with-a-subreport-in-the-reportviewer-control-which-has-a-odata-service-as-datasource-in-a-wpf-application/
另一个可以给你一些好处的网页是: https://blogs.msdn.microsoft.com/sqlforum/2011/01/02/walkthrough-add-a-subreport-in-local-report-in-reportviewer/
关于c# - 带有来自父数据集的子报告的 RDLC 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50637669/