RDLC 报告:将过滤器应用于报告 [英] RDLC Report: Apply Filter to Report
问题描述
我有两个参数 dateFrom
和 dateTo
我想根据这些值过滤我的报告并显示过滤的 total
列的总和报告中的行.
I have two parameters dateFrom
and dateTo
which I want to filter my report based on those values and show sum of total
column of filtered rows in the report.
目前,当我使用表达式 =Sum([total])
时,它返回数据库中整列的总和,并且不会对表达式应用日期过滤器.
Currently when I use expression =Sum([total])
it returns the sum of whole column in database and it doesn't applying date filter on expression.
问题:如何应用日期之间的总和 dateFrom
和 dateTo
参数像这样的伪代码:
Question:
How to apply sum of total between dates dateFrom
and dateTo
parameter like Something like this pseudo-code:
=Sum(Field!Total.Value) where date between dt_from to dt_to
这是我用来加载展示报告的代码:
Here is the code I use to load show report:
invoice_viewTableAdapter.Fill(this.db_posDataSetInvoice.invoice_view);
reportViewer1.RefreshReport();
推荐答案
您应该对报表的数据源应用过滤器,例如:
You should apply the filter on the data source of your report, for example:
invoice_viewTableAdapter.Fill(this.db_posDataSetInvoice.invoice_view);
this.invoice_viewBindingSource.Filter = "Put your filter here";
reportViewer1.RefreshReport();
假设您有一个 MyDateField
字段,并且您有 DateTime
类型的 dateFrom 和 dateTo.
Supposing you have a MyDateField
field and you have dateFrom and dateTo of type of DateTime
.
这可以是您的日期过滤器:
This can be your date filter:
String.Format("MyDateField>= #{0:yyyy/MM/dd}# AND MyDateField<= #{1:yyyy/MM/dd}#"
, dateFrom, dateTo);
您可以找到有关 BindingSource.Filter
表达式语法的更多信息 此处.
you can find more information about about BindingSource.Filter
expression syntax here.
这篇关于RDLC 报告:将过滤器应用于报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!