DashboardConfigurator.SetConnectionStringsProvider(IDataSourceWizardConnectionStringsStorage) Method
Specifies a provider of data connections that can be used by the Web Dashboard.
Namespace: DevExpress.DashboardWeb
Assembly: DevExpress.Dashboard.v24.2.Web.dll
NuGet Package: DevExpress.Web.Dashboard.Common
#Declaration
public void SetConnectionStringsProvider(
IDataSourceWizardConnectionStringsStorage storage
)
#Parameters
Name | Type | Description |
---|---|---|
storage | IData |
A storage that implements the IData |
#Remarks
Use this overload to allow users to save JSON data connections and create new data sources based on them. Follow these steps to implement this:
Set the
AllowCreateNewJsonConnection
property totrue
to allow users to create new JSON data connections at runtime:Platform API HTML Java Script Data Source Wizard Extension Options. allow Create New Json Connection ASP. NET Core Data Source Wizard Option Builder. Allow Create New Json Connection MVC Dashboard Extension Settings. Allow Create New Json Connection Web Forms ASPx Dashboard. Allow Create New Json Connection Implement the IDataSourceWizardConnectionStringsStorage interface to use it as a place where to save the newly created connection strings:
csusing DevExpress.DashboardWeb; public class ConnectionStringProvider: IDataSourceWizardConnectionStringsStorage { readonly Dictionary<string, DataConnectionParametersBase> storage = new Dictionary<string, DataConnectionParametersBase>(); public Dictionary<string, string> GetConnectionDescriptions() { return storage.ToDictionary(p=>p.Key, p=>p.Key); } public DataConnectionParametersBase GetDataConnectionParameters(string name) { return storage[name]; } public void SaveDataConnectionParameters(string name, DataConnectionParametersBase connectionParameters, bool saveCredentials) { storage[name] = connectionParameters; } }
Use the created class instance as the
SetConnectionStringsProvider
‘s parameter so users can reuse the connections and create new JSON data sources at runtime:csusing DevExpress.DashboardWeb; using DevExpress.DataAccess.Web; using DevExpress.DataAccess.ConnectionParameters; using System.Linq; var builder = WebApplication.CreateBuilder(args); builder.Services.AddDevExpressControls(); builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => { DashboardConfigurator configurator = new DashboardConfigurator(); configurator.SetConnectionStringsProvider(new ConnectionStringProvider()); // ... return configurator; }); var app = builder.Build();
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SetConnectionStringsProvider(IDataSourceWizardConnectionStringsStorage) 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.