DashboardExcelDataSource.ConnectionName Property
Specifies the name of the created connection to an Excel data source.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v26.1.Core.dll
NuGet Package: DevExpress.Dashboard.Core
Declaration
Property Value
| Type | Default | Description |
|---|---|---|
| String | null | A connection name. |
Remarks
Use the ConnectionName property to identify the data source for which the ConfigureDataConnection event is raised.
The following code snippet shows how to configure a data connection to an Excel data source:
using System.Web.Routing;
using DevExpress.DashboardWeb;
using DevExpress.DashboardWeb.Mvc;
using System.Web.Hosting;
using DevExpress.DataAccess.Excel;
using DevExpress.DashboardCommon;
namespace DashboardMVC {
public static class DashboardConfig {
public static void RegisterService(RouteCollection routes) {
routes.MapDashboardRoute("dashboardControl");
DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");
DashboardConfigurator.Default.SetDashboardStorage(dashboardFileStorage);
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
// Registers an Excel data source.
DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource("Excel Data Source");
excelDataSource.ConnectionName = "Excel Data Source ID";
excelDataSource.SourceOptions = new ExcelSourceOptions(new ExcelWorksheetSettings("Sheet1"));
dataSourceStorage.RegisterDataSource("excelDataSource", excelDataSource.SaveToXml());
DashboardConfigurator.Default.SetDataSourceStorage(dataSourceStorage);
DashboardConfigurator.Default.ConfigureDataConnection += Configurator_ConfigureDataConnection;
}
private static void Configurator_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
if (e.ConnectionName == "Excel Data Source ID") {
ExcelDataSourceConnectionParameters excelParams = new ExcelDataSourceConnectionParameters(HostingEnvironment.MapPath(@"~/App_Data/Sales.xlsx"));
e.ConnectionParameters = excelParams;
}
}
}
}
See Also