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. :)

 
104
Kudos
 
104
Kudos

Now read this

My little corner

So yeah, after countless aeons I am back. To be honest I’ve tried this before and it has never worked for me, but I figured after travelling the world for a spell it’s time to give it another shot. So, this is all about me. In case you... Continue →