Skip to content

DevExpress-Examples/web-forms-dashboard-pass-hidden-parameters-to-custom-sql-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dashboard for Web Forms - 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 ASPxDashboard.CustomParameters event is handled to change the dashboard parameter's default value before it is passed to the query.

Warning: A user can get sensitive information from dashboard parameters. Encode the passed parameter value if possible. Do not store any sensitive information in dashboard parameters that isn't encrypted.

Example Overview

To pass a hidden dashboard parameter to a custom SQL query, do the following.

Create a Dashboard Parameter

To create a dashboard parameter, open the dashboard menu and go to the Parameters section. In this section, create a parameter and specify its settings. Disable the Visible checkbox to hide the parameter from users in Viewer mode. In this example, the dashboard parameter's name is CountryDashboardParameter and its default value is France:

Create a Dashboard Parameter

Create a Custom Query

Set the ASPxDashboard.AllowExecutingCustomSql property to true to allow custom SQL query execution on the server. To allow users to edit a custom SQL string in the SQL String editor, set the ASPxDashboard.EnableCustomSql property ro true.

Warning: The use of custom SQL queries can lead to inadvertent or unauthorized modifications to your data/database structure. Ensure that you follow best practices and implement the appropriate user read/write privileges at database level.

You can see the query specified for the data source in the Data Source Wizard:

Create a Dashboard Parameter

This query contains a query parameter named CountryParameter.

Bind the Query Parameter to the Dashboard Parameter

To be able to change the query parameter's value, bind it to the CountryDashboardParameter dashboard parameter. To do this, on the second page of the Data Source Wizard set the parameter's type to Expression and specify the corresponding dashboard parameter in the Value field.

Create a Dashboard Parameter

Change the Default Parameter Value in Code

Handle the ASPxDashboard.CustomParameters event and specify the default value: WebForm1.aspx.cs (VB: WebForm1.aspx.vb).

As the result, a user see a dashboard based on the data from the SQL query with the CountryParameter query parameter's value specified in the ASPxDashboard.CustomParameters event handler (Brazil).

Files to Review

Documentation

More Examples