Question

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?

Was it helpful?

Solution

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

MyReportViewer.ServerReport.SetParameters(
    new ReportParameter("storeSelected", new string[] { "2", "3", "4" }, false)
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top