【发布时间】:2016-03-13 01:01:21
【问题描述】:
如果我将一组对象分配给 ReportViewer 的数据源,如何查看每个对象的一个报表页面?
假设我有这样的代码来设置 ReportViewer 的数据源:
var invoice1 = new Invoice() { InvoiceNbr = 1 };
var invoice2 = new Invoice() { InvoiceNbr = 2 };
InvoiceBindingSource.DataSource = new List<Invoice>() { invoice1, invoice2 };
reportViewer1.RefreshReport();
假设 reportViewer1 绑定到一个非常简单的 RDLC 报表,该报表绑定到我的 Invoice 自定义类。该报告有一个绑定到 InvoiceNbr 属性的文本框。
我的问题:如果我运行这段代码,ReportViewer 只显示一页,而不是两页。仅显示 InvoiceNbr 1。
想法: 如果我执行此代码,绑定到 InvoiceNbr 属性的报表文本框必须是聚合值,例如 =First(Fields!InvoiceNbr.Value, "InvoiceGraphDataset") ---注意:如果我改为使用 Fields!InvoiceNbr。值,我收到一个设计时错误,指出该值必须是聚合表达式。
我的问题再次重申: 那么,如何在 ReportViewer 中获得两个报表页面,在一个页面上显示 InvoiceNbr 1,在不同页面上显示 InvoiceNbr 2?我可以在 MS Access 中轻松做到这一点。
编辑:I'm terrified this is the only answer。有人可以确认有比创建带有分页符报告的表格行更好的方法吗?似乎应该有一种更直观的方法来为每个 Invoice 对象制作一个报告页面。帮助?
【问题讨论】:
标签: c# winforms rdlc reportviewer