This example shows how to pass a hidden dasard parameter to a custom SQL query. In this example, the DasardConfigurator.CustomParameters
is handled to change the dasard parameter's default value before it is passed to the query.
Warning: A user can get sensitive information from dasard parameters. Encode the passed parameter value if possible. Do not store any sensitive information in dasard parameters that isn't encrypted.
To pass a hidden dasard parameter to a custom SQL query, do the following.
To create a dasard parameter, open the dasard 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 dasard parameter's name is CountryDasardParameter and its default value is France:
Set the DasardConfigurator.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, call the DataSourceWizardOptionBuilder.EnableCustomSql
method and pass true
as a parameter.
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:
This query contains a query parameter named CountryParameter.
To be able to change the query parameter's value, bind it to the CountryDasardParameter dasard parameter. To do this, on the second page of the Data Source Wizard set the parameter's type to Expression and specify the corresponding dasard parameter in the Value field.
Handle the DasardConfigurator.CustomParameters
event and specify the default value: DasardUtils.cs.
As the result, a user sees a dasard based on the data from the SQL query with the CountryParameter query parameter's value specified in the DasardConfigurator.CustomParameters
event handler (Brazil).
- Dasard for Web Forms - How to pass a hidden dasard parameter to a custom SQL query
- Dasard for Web Forms - How to specify dasard parameter values on the client side
- Dasard for Web Forms - How to update the parameter value when the item's master filter state is changed
(you will be redirected to DevExpress.com to submit your response)