Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS: How to set Multiple Values on ParameterValue object?

The code below gets the values I have entered for my report parameters in a Windows interface I have written for SSRS. However this only works for parameters that do not allow MultiValue. Since Parameter.Value is a string, I don't know how to assign multivalue to it.

    private RE2005.ParameterValue[] GetParamValueSettings()
    {
        var parameters = new RE2005.ParameterValue[_Parameters.Count()];

        for (int i = 0; i < _Parameters.Count(); i++)
        {
            parameters[i] = new RE2005.ParameterValue();
            parameters[i].Name = _Parameters[i].Name;
            **parameters[i].Value = pnlParams.Controls[_Parameters[i].Name].Text;**
        }

        return parameters;
    }

For the line in bold above I did try this as a test: parameters[i].Value = "A,B,C"; (those are valid values)

But the report Throws an error saying that it needs valid values. In the report this is how I display it: = Join(Parameters!myParameter.Value, ", ")

Any advice appreciated, thanks!

like image 949
user259286 Avatar asked Feb 14 '11 22:02

user259286


People also ask

How do I pass multiple values to a parameter in SSRS?

In the Report Data pane, expand the Parameters node, right-click the report parameter that was automatically created for the dataset parameter, and then click Parameter Properties. In the General tab, select Allow multiple values to allow a user to select more than one value for the parameter.

How do you pass multiple value parameters to subreport in SSRS?

What can be done to support sending all values of the parameter to the sub report? Use the JOIN function to combine all the values into a single string that you can pass. An expression that concatenates all the values in the array of a multivalued parameter of type String into one string.


1 Answers

with visual studio 2010, you can initialise the Report parameter with a string array.

with 2005 you may have to add the parameter in multiple times with the same name, but a new value.

This is a proc that would get parameters for a report if there was only one multivalued parameter.

  private RE2005.ParameterValue[] SetParameterValue(string name, string[] values)
    {
        var parameters = new RE2005.ParameterValue[values.Count()];

        for (int i = 0; i < values.Count(); i++)
        {
            parameters[i] = new RE2005.ParameterValue();
            parameters[i].Name = name;
            parameters[i].Value = value;
        }
        return parameters;
    }
like image 61
Nat Avatar answered Sep 28 '22 18:09

Nat