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!
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;
}
链接地址: http://www.djcxy.com/p/50846.html