Multi-value SSRS report parameters from C#
If you are calling SSRS reports from C# and setting the parameters programatically you will sooner or later come across a case where you have to assign a parameter with multiple values. This problem proved quite vexing but I have found the (rather simple) solution so here it is:
string[] foobarValues = new string[] { "foo", "bar", "rnd" };
//Create the list of parameters that will be passed to the report
List reportParameters = new List();
//Set up the multi-value parameter and add the foobarValues array to it
ReportParameter multiValueParam = new ReportParameter("foobar");
multiValueParam.Values.AddRange(foobarValues);
//Finally we add the multi-value parameter to our main parameter list
reportParameters.Add(multiValueParam);
//Set the ReportViewers parameters to the list of ReportParameters we just created
reportViewer.ServerReport.SetParameters(reportParameters.ToArray());
And that is it. Plain and simple. :)
117
Kudos
117
Kudos