I have added a parameter to my report with the option "Allow Multiple Values" checked.
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);
}
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.
Thanks,
Passing multiple parameter values to a report programmatically is a bit trickier. First, you have to use the correct parameter type. In the Field Explorer, add a new parameter and make sure that Allow multiple values and Discrete value(s) are selected.
To specify that a report parameter would accept multiple values, set the MultiValue property of the parameter to True. You can set any parameter type to multivalue except Boolean. The primary use of multivalue parameters is to allow for query restriction clauses based on a set of values.
Just set the parameter value with an array of ints.
report.SetParameterValue("@OrderStatus", new int[]{1,2,3});
in the select expert you would use the in operator.
{table.order_status_id} in {?@OrderStatus}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With