How to: Specify Default Parameter Values 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 specify default parameter values on dashboard loading. To do this, handle the ASPxDashboardViewer.DashboardLoaded event, get access to the dashboard object using the DashboardLoadedWebEventArgs.Dashboard event parameter and specify the default value(s) using the Dashboard.Parameters["parameterName"].Value property.

The ASPxDashboardViewer.ConfigureDataConnection event is handled to customize connection settings before the ASPxDashboardViewer connects to a data store.

using System;
using System.Collections.Generic;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;

namespace WebViewer_DefaultParameterValues {
    public partial class WebForm1 : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
        }

        protected void ASPxDashboardViewer1_DashboardLoaded(object sender, DashboardLoadedWebEventArgs e) {
            // Specifies default parameter values.
            e.Dashboard.Parameters["customerIdParameter"].Value = new List<string>() { "ALFKI", "AROUT", "BONAP" };
        }

        protected void ASPxDashboardViewer1_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
            if (e.DataSourceName == "SQL Data Source 1")
                e.ConnectionParameters = new Access97ConnectionParameters(Server.MapPath("App_Data/nwind.mdb"), "", "");
        }
    }
}