ASPxDashboard.ConfigureDataConnection Event
Allows you to customize connection settings before the ASPxDashboard connects to a data store (database, OLAP cube, etc.).
Namespace: DevExpress.DashboardWeb
Assembly: DevExpress.Dashboard.v19.1.Web.WebForms.dll
Declaration
Event Data
The ConfigureDataConnection event's data class is ConfigureDataConnectionWebEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ConnectionName | Gets the name of the connection for which the event has been raised. Inherited from ConfigureDataConnectionEventArgs. |
ConnectionParameters | Gets or sets parameters used to establish a connection to data. Inherited from ConfigureDataConnectionEventArgs. |
DashboardId | Gets the identifier of the current dashboard. |
DataSourceName | Gets the data source name for which the event was raised. Inherited from DashboardConfigureDataConnectionEventArgs. |
Remarks
The ConfigureDataConnection event is raised before the connection to a data store is established and allows you to customize connection settings.
To specify connection parameters, you have to cast an object returned by the e.ConnectionParameters property to a proper type, depending on the data source type, as the following table illustrates.
Data Source | Parameter Type |
---|---|
Custom Data Source | To specify a custom connection string, cast an object to the CustomStringConnectionParameters class and assign a custom connection string to the ConnectionString property. Tip You can use a custom connection string to get data from an xml file containing valid schema. The string looks as follows: “xpoprovider=InMemoryDataStore;data source=””your_data_file.xml””;read only=True” |
The base type is the SqlServerConnectionParametersBase class which defines the basic connection parameters: DatabaseName, Password, ServerName and UserName. To specify other data provider parameters, cast an object to any of the following types: | |
To specify the OLAP connection string, cast an object to the OlapConnectionParameters type and use the ConnectionString property. | |
To specfy a path to a Microsoft Excel workbook/CSV file, cast an object to the ExcelDataSourceConnectionParameters type and use the FileName and Password properties. | |
To specfy a path to a data extract file and a data driver to access the data, cast an object to the ExtractDataSourceConnectionParameters type and use the FileName and DriverName properties. | |
Event does not occur. | |
Event does not occur. Handle the DataLoading event instead. |
This event is raised when the dashboard is supplied with data using one of the following data source types:
Note
If the dashboard is supplied with data using the DashboardObjectDataSource data source, the ASPxDashboard.DataLoading event is fired instead.
The following code snippet shows how to configure data connections for SQLite, Excel, and OLAP data sources:
private void ASPxDashboard1_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
if (e.ConnectionName == "sqliteConnection") {
SQLiteConnectionParameters sqliteParams = new SQLiteConnectionParameters();
sqliteParams.FileName = "file:Data/nwind.db";
e.ConnectionParameters = sqliteParams;
}
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;
}
if (e.DataSourceName == "Excel Data Source") {
ExcelDataSourceConnectionParameters excelParams = new ExcelDataSourceConnectionParameters(HttpContext.Current.Server.MapPath("App_Data/Sales.xlsx"));
e.ConnectionParameters = excelParams;
}
}