This example shows how to pass a dashboard parameter to a stored procedure. In this example, the DashboardDesigner.CustomParameters event is handled to change the dashboard parameter's default value before it is passed to the stored procedure.
In the result, only the values specified in the CustomParameters event are in effect.
To pass a dashboard parameter to a stored procedure, do the following.
To 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.
In this example, the orderIDs dashboard parameter is created. Specify the following settings:
- Enable the
Allow Multiselectproperty to select multiple values for the parameter. - Set the
Look-up Settingsproperty to Static List. The following values are available for the parameter: 10248, 10249, 10250. - Enable the
Select Allproperty to select all values in the initial state of the dashboard.
In the Query Editor dialog, select a stored procedure. In this example, the GetOrdersByID stored procedure from the NWind.mdf database is used.
On the next page, bind the query parameter to the dashboard parameter created earlier.
You cannot pass a multi-value parameter value to a stored procedure directly. To pass a multi-value parameter to a stored procedure, convert the array of parameter values to a string with the JOIN() function if you use the Microsoft SQL Server, MySQL, or Oracle database system. The stored procedure code should parse the resulting string to get the dashboard parameter values.
To do this, on the second page of the Query Editor, enable the Expression check box for the query parameter. From the drop-down list in the Value column, select the Expression Editor option.
In the invoked Expression Editor, pass the name of the dashboard parameter (?OrderIDS) to the JOIN() function.
Click OK to apply the specified settings.
Handle the DashboardDesigner.CustomParameters event and specify the value to be passed to the stored procedure.
private void DashboardDesigner_CustomParameters(object sender, DevExpress.DashboardCommon.CustomParametersEventArgs e) {
var customerIDsparam = e.Parameters.FirstOrDefault(p => p.Name == "orderIDs"); ;
if (customerIDsparam != null) {
customerIDsparam.Value = new string[] {"10251", "10252", "10253", "10254"} ;
}
}As a result, a user sees a dashboard based on the data from the stored procedure with the data query parameter's value specified in the DashboardDesigner.CustomParameters event handler (10251, 10252, 10253, 10254).
- Create a Dashboard Parameter
- Reference Dashboard Parameters
- Specify Dashboard Parameter Values
- Stored Procedures
- Dashboard for WinForms - Pass a Hidden Dashboard Parameter to a Custom SQL query
- Dashboard for WinForms - Pass a Dashboard Parameter to a Custom SQL Query in Code
- 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 - 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
(you will be redirected to DevExpress.com to submit your response)




