Back to Devexpress

IDashboardStorage.SaveDashboard(String, XDocument) Method

dashboard-devexpress-dot-dashboardweb-dot-idashboardstorage-dot-savedashboard-x28-system-dot-string-system-dot-xml-dot-linq-dot-xdocument-x29.md

latest3.6 KB
Original Source

IDashboardStorage.SaveDashboard(String, XDocument) Method

Saves the specified dashboard to the current IDashboardStorage.

Namespace : DevExpress.DashboardWeb

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

NuGet Package : DevExpress.Web.Dashboard.Common

Declaration

csharp
void SaveDashboard(
    string dashboardID,
    XDocument dashboard
)
vb
Sub SaveDashboard(
    dashboardID As String,
    dashboard As XDocument
)

Parameters

NameTypeDescription
dashboardIDString

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 CoreView Example: ASP.NET MVCView Example: ASP.NET Web Forms

See Also

LoadDashboard(String)

IDashboardStorage Interface

IDashboardStorage Members

DevExpress.DashboardWeb Namespace