How to: Customize Connection Settings before ASPxDashboardViewer Connects to a Database
- 3 minutes to read
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:
ASPxDashboardViewer -> ASPxDashboard
How to migrate from ASPxDashboardViewer to ASPxDashboard working in the ViewerOnly mode
MVCxDashboardViewer -> MVCxDashboard
How to migrate from DashboardViewerExtension to DashboardExtension working in the ViewerOnly mode
This example demonstrates how to customize connection settings before ASPxDashboardViewer connects to a database using the ASPxDashboardViewer.ConfigureDataConnection event.
In this example, the dashboard visualizes data from the secured Microsoft Access database. To visualize data from this database file, it is necessary to provide connection parameters (a path to the database file, a user name and a password for authentication).
- The FileConnectionParametersBase.FileName property specifies the path to a database file.
- The Access97ConnectionParameters.UserName and FileConnectionParametersBase.Password event parameters are used to provide the user name and password respectively.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-customize-connection-settings-before-aspxdashboardviewer-connects-to-a-database-t198248.
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="Dashboard_ConfigureDataConnection_Web.WebForm1" %>
<%@ Register Assembly="DevExpress.Dashboard.v15.1.Web, Version=15.1.7.0,
Culture=neutral,
PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxDashboardViewer ID="ASPxDashboardViewer1" runat="server"
onconfiguredataconnection="ASPxDashboardViewer1_ConfigureDataConnection"
Height="800px" Width="1200px">
</dx:ASPxDashboardViewer>
</div>
</form>
</body>
</html>