This example shows how to change a default or user-defined dashboard parameter value in the DashboardViewer.CustomParameters
event handler. The effective parameter value is hidden from users. Set the Visible
property to false
to hide the parameter from the Dashboard Parameters dialog.
In this example, the parameterState dashboard parameter with static look-up settings is added to the dashboard. This dashboard parameter is used to filter the data source. The Dashboard Parameters dialog displays the values and enables users to select a parameter value from the list. In the DashboardViewer.CustomParameters
) event handler, we can change the value supplied by the user before it is passed to the query.
In the result, the value defined in the DashboardViewer.CustomParameters
event is in effect.
C#
private void DashboardViewer_CustomParameters(object sender, CustomParametersEventArgs e) {
var customParameter = e.Parameters.FirstOrDefault(p => p.Name == "parameterState");
if (customParameter != null) {
// Actual value used when retrieving data from the data source.
customParameter.Value = "Nevada";
}
}
Visual Basic
Private Sub DashboardViewer_CustomParameters(ByVal sender As Object, ByVal e As CustomParametersEventArgs)
Dim customParameter = e.Parameters.FirstOrDefault(Function(p) p.Name = "parameterState")
If customParameter IsNot Nothing Then
' Actual value used when retrieving data from the data source.
customParameter.Value = "Nevada"
End If
End Sub
- ViewerForm1.cs (VB: ViewerForm1.vb)
- How to: Pass a Dashboard Parameter to a Filter String in Code
- How to: Pass a Dashboard Parameter to a Calculated Field's Expression in Code
- How to: Pass a Dashboard Parameter to a Custom SQL Query in Code
- How to: Pass a Hidden Dashboard Parameter to a Custom SQL Query in the WinForms Viewer
- How to: Specify Default Parameter Values in the WinForms Viewer
- How to: Use Dashboard Parameters with the Expression Format Condition
- How to: Display the Others Slice in the Pie Chart