dashboard-devexpress-dot-dashboardweb-dot-idashboardstorage-dot-savedashboard-x28-system-dot-string-system-dot-xml-dot-linq-dot-xdocument-x29.md
Saves the specified dashboard to the current IDashboardStorage.
Namespace : DevExpress.DashboardWeb
Assembly : DevExpress.Dashboard.v25.2.Web.dll
NuGet Package : DevExpress.Web.Dashboard.Common
void SaveDashboard(
string dashboardID,
XDocument dashboard
)
Sub SaveDashboard(
dashboardID As String,
dashboard As XDocument
)
| 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.
|
Implement the IDashboardStorage.LoadDashboard method to load the dashboard with the specified identifier from the current IDashboardStorage.
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.
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