Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set multiple integer ReportParameter in c#?

I am using Report Builder and loading the report in c#, also setting some parameters in c# too:

My question is, how do I set a ReportParameter of multiple integer values when I have it stored in an array?

I have tried the following:

 MyReportViewer.ServerReport.SetParameters(
      new ReportParameter("storeSelected", new int[3]{2,3,4}, false)
 );

However, this does not work, because ReportParameter does not take int.

I have also tried the following:

 MyReportViewer.ServerReport.SetParameters(
      new ReportParameter("storeSelected", new int[3]{"2", "3", "4" }, false)
 );

This also does not work as my parameter "storeSelected" is of type int, and will throw a type conversion error.

What do I need to do to pass my array of integer into the reportParameter?

like image 935
Bill Software Engineer Avatar asked Apr 08 '13 18:04

Bill Software Engineer


1 Answers

Based on the documentation by Microsoft, this line of code should read:

MyReportViewer.ServerReport.SetParameters(
    new ReportParameter("storeSelected", new string[] { "2", "3", "4" }, false)
);
like image 108
Mike Perrenoud Avatar answered Nov 18 '22 11:11

Mike Perrenoud