RDLC Report: Apply Filter to Report

雨燕双飞 提交于 2019-12-20 03:14:49

问题


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.

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.

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();

回答1:


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();

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);

you can find more information about about BindingSource.Filter expression syntax here.



来源:https://stackoverflow.com/questions/33994830/rdlc-report-apply-filter-to-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!