The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Pass a Hidden Dashboard Parameter to a Custom SQL Query in the Web Viewer

Important

This documentation applies to v16.2. Starting with v17.1, the ASPxDashboardViewer control is in maintenance mode. In v19.1, the new Web Dashboard Control replaces the old Web Dashboard Viewer. This means that the Web Dashboard Viewer will not be included in our installation packages. See our blog post for more information.

Refer to the following KB articles to learn how to migrate to ASPxDashboard / ASP.NET MVC Dashboard:

The following example shows how to filter a custom SQL query by changing a parameter value in the ASPxDashboardViewer.CustomParameters event handler.

In this example, the custIDQueryParameter query parameter is included in a WHERE clause of a custom SQL query. The custIDQueryParameter parameter is also bound to the hidden custIDDashboardParameter dashboard parameter. The value of this parameter is changed at runtime by handling the ASPxDashboardViewer.CustomParameters event which is raised before the ASPxDashboardViewer sends a query to a database.

Imports System
Imports System.Linq
Imports DevExpress.DashboardWeb
Imports DevExpress.DataAccess.ConnectionParameters

Namespace Dashboard_CustomParameters_Web
    Partial Public Class WebForm1
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        End Sub

        Protected Sub ASPxDashboardViewer1_CustomParameters(ByVal sender As Object, _
                                                            ByVal e As CustomParametersWebEventArgs)
            Dim custIDParameter = e.Parameters.FirstOrDefault(Function(p) p.Name = "custIDDashboardParameter")
            If custIDParameter IsNot Nothing Then
                custIDParameter.Value = "AROUT"
            End If
        End Sub

        Protected Sub ASPxDashboardViewer1_ConfigureDataConnection(ByVal sender As Object, _
                                                                   ByVal e As ConfigureDataConnectionWebEventArgs)
            If e.DataSourceName = "SQL Data Source 1" Then
                Dim parameters As Access97ConnectionParameters =
                    CType(e.ConnectionParameters, Access97ConnectionParameters)
                Dim databasePath As String = Server.MapPath("App_Data/nwind.mdb")
                parameters.FileName = databasePath
            End If
        End Sub
    End Class
End Namespace