Skip to main content
All docs
V26.1
  • ASPxDashboard.SetConnectionStringsProvider(IDataSourceWizardConnectionStringsStorage) Method

    Specifies a provider of data connections that can be used by the Web Dashboard.

    Namespace: DevExpress.DashboardWeb

    Assembly: DevExpress.Dashboard.v26.1.Web.WebForms.dll

    Declaration

    public void SetConnectionStringsProvider(
        IDataSourceWizardConnectionStringsStorage storage
    )

    Parameters

    Name Type Description
    storage IDataSourceWizardConnectionStringsStorage

    A storage that implements the IDataSourceWizardConnectionStringsStorage interface and allows you to save the created JSON data connections.

    Remarks

    Use the following overload to allow end users to save JSON data connections and create new data sources based on them.

    To enable the capability to create new JSON data connections for end users, set the ASPxDashboard.AllowCreateNewJsonConnection property to true.

    Implement the IDataSourceWizardConnectionStringsStorage interface and use the created class instance as a method’s parameter.

    using DevExpress.DashboardWeb;
    using DevExpress.DataAccess.Web;
    using DevExpress.DataAccess.ConnectionParameters;
    using System.Linq;
    // ...
    
    public partial class Default : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {
          // ...
          ASPxDashboard1.AllowCreateNewJsonConnection = true;
          ASPxDashboard1.SetConnectionStringsProvider(new ConnectionStringProvider());
        }
    }
    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;
        }
    }
    
    See Also