我有两个参数 dateFrom
和 dateTo
,我想根据这些值过滤我的报告并显示过滤后的 total
列的总和报告中的行。
目前,当我使用表达式 =Sum([total])
时,它会返回数据库中整列的总和,并且不会对表达式应用日期过滤器。
问题:
如何应用日期 dateFrom
和 dateTo
参数之间的总和,就像这样的伪代码:
=Sum(Field!Total.Value) where date between dt_from to dt_to
这是我用来加载显示报告的代码:
invoice_viewTableAdapter.Fill(this.db_posDataSetInvoice.invoice_view);
reportViewer1.RefreshReport();
最佳答案
您应该对报告的数据源应用过滤器,例如:
invoice_viewTableAdapter.Fill(this.db_posDataSetInvoice.invoice_view);
this.invoice_viewBindingSource.Filter = "Put your filter here";
reportViewer1.RefreshReport();
假设您有一个 MyDateField
字段,并且您有 DateTime
类型的 dateFrom 和 dateTo。
这可以是您的日期过滤器:
String.Format("MyDateField>= #{0:yyyy/MM/dd}# AND MyDateField<= #{1:yyyy/MM/dd}#"
, dateFrom, dateTo);
您可以找到有关 BindingSource.Filter
表达式语法 here 的更多信息.
关于c# - RDLC报告: Apply Filter to Report,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33994830/