问题描述
我在报告中添加了一个参数,并勾选了允许多个值"选项.
I have added a parameter to my report with the option "Allow Multiple Values" checked.
这是一个状态列(IE、已提议、进行中、已完成、已取消),我希望用户能够选择要报告哪些(以及多少个)不同的 OrderStatus.
This is a status column (IE, Proposed, In Progress, Completed, Canceled), and I want the user to be able to select which (and how many) different OrderStatus to report on.
我通常如何设置参数是:
How I normally set parameters is:
report.SetParameterValue("@dtBegin", dtBegin.DateTime);
我尝试为多个值做的事情是这样的:
What I tried to do for the multiple values was something like this:
//pseudo loop
foreach(int intOrderStatus in intSelectedOrderStatuses)
{
report.Parameter_OrderStatus.CurrentValues.AddValue(intOrderStatus);
}
我检查过它确实将值添加到 OrderStatus 参数,但是当报表运行时,CrystalReports 对话框弹出并要求我输入 OrderStatus 参数的值.所以似乎这些值没有提交"到参数.我已经进行了多次搜索,但无法弄清楚为什么它不起作用.
I have checked it does add the values to the OrderStatus parameter, but when the report runs, the CrystalReports dialog pops up and asks me to enter values for the OrderStatus parameter. So it seems as though the values aren't "commited" to the parameter. I have done a number of searches and can't figure out why it's not working.
谢谢,
推荐答案
只需用int数组设置参数值即可.
Just set the parameter value with an array of ints.
report.SetParameterValue("@OrderStatus", new int[]{1,2,3});
在选择专家中,您将使用 in 运算符.
in the select expert you would use the in operator.
{table.order_status_id} in {?@OrderStatus}
这篇关于为 Crystal Reports 中的参数分配多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!