DashboardConfigurator.SetConnectionStringsProvider(IDataSourceWizardConnectionStringsProvider) Method
Specifies a provider of data connections that can be used by the Web Dashboard.
Namespace: DevExpress.DashboardWeb
Assembly: DevExpress.Dashboard.v24.1.Web.dll
NuGet Package: DevExpress.Web.Dashboard.Common
Declaration
public void SetConnectionStringsProvider(
IDataSourceWizardConnectionStringsProvider provider
)
Parameters
Name | Type | Description |
---|---|---|
provider | IDataSourceWizardConnectionStringsProvider | An object that implements the IDataSourceWizardConnectionStringsProvider interface and provides access to the predefined connections strings. |
Remarks
Pass the ConfigFileConnectionStringsProvider instance (DashboardConnectionStringsProvider for ASP.NET Core) as a method’s parameter for a default connection string provider implementation to allow end users to create new data sources based on predefined connection strings.
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.Web;
// ...
DashboardConfigurator.Default.SetConnectionStringsProvider(new ConfigFileConnectionStringsProvider());
Important
To learn how to use the DashboardConfigurator‘s API, see the Server-Side API Overview topic.
This example shows how to implement a custom provider of connection strings by implementing the IDataSourceWizardConnectionStringsProvider interface.
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Web;
// ...
public class MyDataSourceWizardConnectionStringsProvider : IDataSourceWizardConnectionStringsProvider {
public Dictionary<string, string> GetConnectionDescriptions() {
Dictionary<string, string> connections = new Dictionary<string, string>();
// Customize the loaded connections list.
connections.Add("jsonUrlConnection", "JSON URL Connection");
connections.Add("msSqlConnection", "MS SQL Connection");
return connections;
}
public DataConnectionParametersBase GetDataConnectionParameters(string name) {
// Return custom connection parameters for the custom connection.
if (name == "jsonUrlConnection") {
return new JsonSourceConnectionParameters() {
JsonSource = new UriJsonSource(
new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"))
};
} else if (name == "msSqlConnection") {
return new MsSqlConnectionParameters("localhost", "Northwind", "", "", MsSqlAuthorizationType.Windows);
}
throw new System.Exception("The connection string is undefined.");
}
}
After you implemented a custom provider of connection strings, pass the instance of this class to the DashboardConfigurator.SetConnectionStringsProvider
method.
using DevExpress.DashboardWeb;
// ...
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
// ...
DashboardConfigurator.Default.SetConnectionStringsProvider(new MyDataSourceWizardConnectionStringsProvider());
}
// ...
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SetConnectionStringsProvider(IDataSourceWizardConnectionStringsProvider) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.