Skip to main content

IDashboardStorage.SaveDashboard(String, XDocument) Method

Saves the specified dashboard to the current IDashboardStorage.

Namespace: DevExpress.DashboardWeb

Assembly: DevExpress.Dashboard.v24.2.Web.dll

NuGet Package: DevExpress.Web.Dashboard.Common

#Declaration

void SaveDashboard(
    string dashboardID,
    XDocument dashboard
)

#Parameters

Name Type Description
dashboardID String

A String value that specifies the dashboard identifier.

dashboard XDocument

A XDocument object that is the XML definition of the dashboard to be saved.

#Remarks

Implement the IDashboardStorage.LoadDashboard method to load the dashboard with the specified identifier from the current IDashboardStorage.

#Example

This example shows how to create custom dashboard storage in an ASP.NET Core application and to store dashboards in a database. The SaveDashboard method is used to save the specified dashboard with new settings to the dashboard storage.

View Example: ASP.NET Core

cs
public void SaveDashboard(string dashboardID, XDocument document) {
    using (SqlConnection connection = new SqlConnection(connectionString)) {
        connection.Open();
        MemoryStream stream = new MemoryStream();
        document.Save(stream);
        stream.Position = 0;

        SqlCommand InsertCommand = new SqlCommand(
            "UPDATE Dashboards Set Dashboard = @Dashboard " +
            "WHERE ID = @ID");
        InsertCommand.Parameters.Add("ID", SqlDbType.Int).Value = Convert.ToInt32(dashboardID);
        InsertCommand.Parameters.Add("Dashboard", SqlDbType.VarBinary).Value = stream.ToArray();
        InsertCommand.Connection = connection;
        InsertCommand.ExecuteNonQuery();

        connection.Close();
    }
}

The following examples are based on different platforms and show how to create a custom dashboard storage to load and save dashboards to a database:

View Example: ASP.NET Core View Example: ASP.NET MVC View Example: ASP.NET Web Forms

See Also