Dashboard for WinForms - How to Pass a Hidden Dashboard Parameter to a Custom SQL query
This example shows how to pass a hidden dashboard parameter to a custom SQL query. In this example, the DashboardViewer.CustomParameters
event is handled to change the dashboard parameter's default value before it is passed to the query.
To pass a hidden dashboard parameter to a custom SQL query, do the following.
In the Dashboard Designer, create a dashboard parameter.
Click the Parameters button from the Dashboard page group on the Ribbon's Home page. Click Add to create a dashboard parameter. Diasble the Visible property to hide the parameter from the Dashboard Parameters dialog. In this example, the dashboard parameter's name is custIDDashboardParameter and its default value is ALFKI:
Custom SQL queries are disabled by default. To allow users to specify custom SQL queries in the Query Builder/Query Editor, set the SqlWizardSettings.EnableCustomSql
property exposed by the DashboardDataSourceWizardSettings
class to true
. Add the following code to allow custom SQL queries:
dashboardDesigner1.DataSourceWizard.SqlWizardSettings.EnableCustomSql = true;
Specify the query in the SQL string editor in the Query Builder/Query Editor:
This query contains a query parameter named custIDQueryParameter.
To change the query parameter value dynamically, bind it to the custIDDashboardParameter dashboard parameter. To do this, on the next page of the Query Editor, click Add to create a query parameter. Specify the parameter settings. In the Name column, specify the name used in the query. Select the Expression check box and bind the query parameter to the dashboard parameter:
Click Finish.
Load the created dashboard to the Dashboard Viewer.
Handle the DashboardViewer.CustomParameters
event and specify the value to be passed to the query: Form1.cs (VB: Form1.vb).
As a result, a user sees a dashboard based on the data from the SQL query with the custIDQueryParameter query parameter's value specified in the DashboardViewer.CustomParameters
event handler (AROUT).
- Dashboard Parameters
- Specify Dashboard Parameter Values in the Dashboard Viewer
- Reference Dashboard Parameters
- Dashboard for WinForms - Pass a Dashboard Parameter to a Filter String in Code
- Dashboard for WinForms - Pass a Dashboard Parameter to a Calculated Field's Expression in Code
- Dashboard for WinForms - Pass a Dashboard Parameter to a Custom SQL Query in Code
- Dashboard for WinForms - Specify Default Parameter Values in the WinForms Viewer
- Dashboard for WinForms - Use Dashboard Parameters with the Expression Format Condition
- Dashboard for WinForms - Manage Parameters in the WinForms Viewer
- Dashboard for WinForms - Display the Others Slice in the Pie Chart
(you will be redirected to DevExpress.com to submit your response)