views:

294

answers:

1

I have a Winforms application that uses the ReportViewer control to display SSRS reports. I have one report with many paramters that must be set by the user. I specifically set one of the parameters to have no default value so that the parameter prompts would display in the report viewer prior to running the report.

However, when the report viewer displays, the parameter prompts do not display and a message reads, "This report requires a default or user-defined value for the report parameter 'ReservationStatus'. To run or subscribe to this report, you must provide a parameter value."

If I do a ReportViewer.RefreshReport(), the prompts display. However, I don't want to call this because I also call the ReportViewer.SetDisplayMode() method to put it in print mode. This method supposedly calls the RefreshReport() method.

Also, the Show / Hide Parameter button is grayed out when the form first displays. If I click the refresh button, then the parameter button is enabled. It's a if the viewer is not picking up the parameters until a refresh is called.

Can someone explain why I can't seem to just have the viewer prompt for parameters first, then try to refresh / run the report?

A: 

Setting the ReportViewer.Messages property on the report control causes the parameter pane to refresh. I was able to replace RefreshReport with this:

ReportViewer.Messages = ReportViewer.Messages

A trip to .NET Reflector explains why:

  • ReportViewer.Messages calls rsParams.ApplyCustomResources
  • rsParams.ApplyCustomResources calls rsParams.EnsureParamsLoaded

The only other method that calls rsParams.EnsureParamsLoaded is RefreshReport. And the method is Private so there is no hope to use inheritance. Setting the Messages to itself, although extremely hokey, is the only workaround I can find.

Vince