How to check the parameters values input by the user in the parameters toolbar

Attachments

Version 2.6 of Silverlight Viewer for Reporting Services features an ability to check the parameters values, input by a user.
In order to get the values, input by the user in the parameters toolbar, it is needed to subscribe to the ParametersProcessing event of the ReportViewer object.

Example:

reportViewer.ParametersProcessing += 
new EventHandler<ParametersProcessingEventArgs>
(reportViewer_ParametersProcessing);

You can check and change the report parameters values in the event handler. You can continue or cancel the document rendering if parameters values are input incorrectly. In order the user could change the incorrect values; you can set the ShowParametersPanel property of the ParametersProcessingEventArgs object equal to true. In this case the parameters toolbar won’t be hidden.

Example:

if (e.Collection.Count(p => p.Name == "ReportParameter3") > 0)
  {
    e.Collection.First(p => p.Name == "ReportParameter3").Value = 
    "value from code";
  }
if (e.Collection.Count(p => p.Name == "ReportParameter4") > 0)
  {
    int param4Value = 
    int.Parse(e.Collection.First(p=>p.Name=="ReportParameter4").Value);
    if (!(param4Value > 3 && param4Value < 10))
    {
       e.CancelRender = true;
       e.ShowParametersPanel = true;
       ChildWindow1 frm = new ChildWindow1();
       frm.Show();
    }
  }

In the example, you can see the change of the value of the "ReportParameter3" parameter and checking the correctness of the value of the "ReportParameter4" parameter. If the "ReportParameter4" parameter value is correct, then the document rendering will be continued. If the "ReportParameter4" parameter value is incorrect, then the parameters toolbar and the message about incorrect parameter value will be shown.

Input of parameters values:

Message about incorrect parameter value:

Add Feedback