alanjuden / MvcReportViewer

Custom Report Viewer control to replace MS Report Viewer on MVC projects (also works on .NET Core as a Report Viewer).
MIT License
173 stars 109 forks source link

SetParameters causing dictionary collision #20

Closed mtinnes closed 7 years ago

mtinnes commented 7 years ago

The SetParameters() function in ReportExportResult is using the report parameter label as a key, which is causing a collision with our dataset. The offending code is:

if (definedReportParameter.ValidValues != null)
{
  foreach (var validValue in definedReportParameter.ValidValues)
  {
    reportParameter.ValidValues.Add(validValue.Label, validValue.Value);
  }
}

check needed before inserting into ValidValues

alanjuden commented 7 years ago

@mtinnes: could you give me any more info about the setup of your report? The "validValue" object is coming from the SSRS api (from definedReportParameter.ValidValues).

Could you maybe explain the parameters in use on your report as well as if you have any duplicated values that are valid values in the option list? If your issue is coming from the ValidValues.Add line then it indicates you have more than one value with the same name in your parameter's "Available Values" section of your report.

SSRS only provides two fields for me to use on the available values (Label, and Value). Just as defined in reports.

I've attached a picture of a sample report on where to be checking for duplicates.

image

notice you only have two fields (Label and Value).

As an example on my report, it would be as if I had the following:

Value | Country (Label)

1 | United States 2 | United States 3 | Canada 4 | Mexico

I'm totally willing to help here just looking for what's actually happening as I haven't run into this issue myself.

mtinnes commented 7 years ago

Thanks @alanjuden, you are right on, we have values which have identical labels. I don't see that the dictionary is being used and could possibly be changed to a simple list?