问题
I am hooking up a site with an embeded ReportViewer control. I need to pass a Multi-value parameter (string data type) to the report. I have tried using the following methods but each time the report errors with a parameter is missing a value.
here is the method I am using:
string s = String.Join(",", paramValue.ToArray());
// method 2 carriage return new line delimited string
string s = String.Join("/r/n", paramValue.ToArray()) + "/r/n";
// method 3 values as a string array
string[] s = paramValue.ToArray();
paramList.Add(new ReportParameter("ParamName", s, false));
Obviously the above code is not exactly what I am using but it does show the variations I have tried.
None of the above works. please help me with this problem.
回答1:
You have to add it as an Array to the Values
property of type StringCollection
.
List<ReportParameter> rptParams = new List<ReportParameter>();
ReportParameter param = new ReportParameter("ParamName");
string[] values = new string[]{"a", "b", "c"};
param.Values.AddRange(values);
rptParams.Add(param);
this.ReportViewer1.ServerReport.SetParameters(rptParams);
来源:https://stackoverflow.com/questions/18002218/how-to-pass-multi-value-parameter-to-ssrs-from-asp-net-c