ReportViewer和过滤 [英] ReportViewer and filtering

查看:65
本文介绍了ReportViewer和过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我尝试手动;没有向导,填充ReportViewer控件。通过使用我创建的SQL数据访问实用程序类,我成功地这样做了。但我希望能够过滤报告的结果,因此,我探索了传入参数和基于传入的参数的过滤。这也有效,但是通过在报告中的字段上放置参数,如果做的话没有设置;在别人的话中,它留空,报告本身是空的。我的结果是存在,但它们没有显示,因为过滤器正在加载时应用;我可以告诉,因为我在页面上有其他文本框,通过我写的一些表达式来利用报告的值。



有没有办法通过默认忽略过滤器,最初在加载?我不是最擅长使用ReportViewer,但我正在学习,所以如果我问一些看似愚蠢的问题,请耐心等待。此外,如果在运行时不再使用过滤器,有没有办法删除过滤器?

Hello,

I am try to manually; no wizard, populate a the ReportViewer control. I have been successful in doing so, by using a SQL Data Access utility class I've created. But I wanted to be able to filter result of the report as well, and as such, I explored passing in parameters and filtering based on the paramater passed in. This also works, but by placing a parameter on a field in report, if do not set; in others words leave it empty, the report itself is empty. I result are there but they are not being shown, because the filter is being applied on load; I can tell because I have other textboxes on the page that make use of the values of the report via some expressions I've written.

Is there a way to by default ignoring the filter, initially on load? I am not the best at using the ReportViewer but I am learning so please be patient with me if I ask some seemingly dumb questions. Also, is there a way to remove a filter once you no longer have use for it during runtime?
.

推荐答案

首先,这根本不是一个愚蠢的问题:)

根据你的问题,让我画一个场景。假设您在单个sql表中拥有属于2个不同系统的数据。如果您将系统ID 1作为报告参数传递,则您成功过滤属于系统1的数据。如果您传递系统ID 2,则过滤以获取系统2的数据。您希望在报告加载时使用默认过滤器(以防万一)你还没有实际传递报告参数,即系统ID 1或2 ......假设你已经传递了一个未初始化的参数0)。这是正确的吗?



如果是这样,请更改过滤条件表达式,例如

=参数!SystemIDParm.Value



=参数!SystemIDParm.Value OR Fields!SystemID.Value



第二个表达式查找传递的报告参数过滤数据...如果找不到它,它将只返回系统1和系统2的数据。



希望这是有意义的。祝你好运!
First of all,it is not a dumb question at all :)
Based on your question, let me paint a scenario. Say you have data belonging to 2 different systems in a single sql table. If you pass the system id 1 as a report parameter, you successfully filter the data belonging to system 1. If you pass system id 2, you filter to get data for system 2. You want a default filter when the report loads (in case you haven't actually passed the report parameter i.e. System ID 1 or 2...let's say you have passed an uninitialised parameter 0). Is this correct?

If so, change your filter criteria expression from something like
=Parameters!SystemIDParm.Value
to
=Parameters!SystemIDParm.Value OR Fields!SystemID.Value

The second expression looks for the passed report parameter to filter the data on...if it can't find it, it will just return data for both system 1 and system 2.

Hope that makes sense. Good luck!


这篇关于ReportViewer和过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆