dashboard-401409-web-dashboard-integrate-dashboard-component-aspnet-web-forms-dashboard-control-register-default-data-sources-olap-data-source.md
This topic shows how to add the DashboardOlapDataSource to an in-memory data source storage, and make it available to users.
For example, your ASPX page contains the ASPxDashboard control which unique identifier is ASPxDashboardOlap:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="position: absolute; top: 0; bottom: 0; left: 0; right: 0">
<dx:ASPxDashboard ID="ASPxDashboardOlap" runat="server" Width="100%" Height="100%">
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>
You can define the OLAP data source in the code-behind page that has the .aspx.cs or .aspx.vb extension depending on the language used:
Create a DashboardOlapDataSource instance.
Specify the DashboardOlapDataSource.ConnectionName property to uniquely identify the data connection in code.
Handle the ASPxDashboard.ConfigureDataConnection or DashboardConfigurator.ConfigureDataConnection event:
Register the created data source instance in the data source storage.
Note
A code-behind page is one of the variants where you can register the data sources. For example, you can also register them in the Global.asax.cs (Global.asax.vb) file.
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;
using System;
namespace WebFormsDashboardDataSources.Pages {
public partial class OlapDashboard : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
// ...
// Create a data source storage.
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
// Register an OLAP data source.
DashboardOlapDataSource olapDataSource = new DashboardOlapDataSource("OLAP Data Source", "olapConnection");
dataSourceStorage.RegisterDataSource("olapDataSource", olapDataSource.SaveToXml());
// Set the configured data source storage.
ASPxDashboardOlap.SetDataSourceStorage(dataSourceStorage);
ASPxDashboardOlap.ConfigureDataConnection += ASPxDashboardOlap_ConfigureDataConnection;
ASPxDashboardOlap.InitialDashboardId = "dashboardOlap";
}
private void ASPxDashboardOlap_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
if (e.ConnectionName == "olapConnection") {
OlapConnectionParameters olapParams = new OlapConnectionParameters();
olapParams.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;"
+ "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;";
e.ConnectionParameters = olapParams;
}
}
}
}
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWeb
Imports DevExpress.DataAccess.ConnectionParameters
Imports System
Namespace WebFormsDashboardDataSources.Pages
Public Partial Class OlapDashboard
Inherits Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' ...
' Create a data source storage.
Dim dataSourceStorage As DataSourceInMemoryStorage = New DataSourceInMemoryStorage()
' Register an OLAP data source.
Dim olapDataSource As DashboardOlapDataSource = New DashboardOlapDataSource("OLAP Data Source", "olapConnection")
dataSourceStorage.RegisterDataSource("olapDataSource", olapDataSource.SaveToXml())
' Set the configured data source storage.
ASPxDashboardOlap.SetDataSourceStorage(dataSourceStorage)
AddHandler ASPxDashboardOlap.ConfigureDataConnection, AddressOf Me.ASPxDashboardOlap_ConfigureDataConnection
ASPxDashboardOlap.InitialDashboardId = "dashboardOlap"
End Sub
Private Sub ASPxDashboardOlap_ConfigureDataConnection(ByVal sender As Object, ByVal e As ConfigureDataConnectionWebEventArgs)
If Equals(e.ConnectionName, "olapConnection") Then
Dim olapParams As OlapConnectionParameters = New OlapConnectionParameters()
olapParams.ConnectionString = "Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" & "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
e.ConnectionParameters = olapParams
End If
End Sub
End Class
End Namespace
The OLAP Data Source is now available in the Web Dashboard:
Users can bind dashboard items to data in the Web Dashboard’s UI.
Users can use the Dashboard Data Source Wizard to create a new OLAP data source based on an existing connection.
See the following topic for details: Specify Data Source Settings (OLAP).
The example shows how to make a set of data sources available for users in the Web Dashboard application.
View Example: How to Register Data Sources for ASP.NET Web Forms Dashboard Control