dashboard-devexpress-dot-dashboardweb-dot-ieditabledashboardstorage-dot-adddashboard-x28-system-dot-xml-dot-linq-dot-xdocument-system-dot-string-x29.md
Adds a new dashboard to the current IEditableDashboardStorage.
Namespace : DevExpress.DashboardWeb
Assembly : DevExpress.Dashboard.v25.2.Web.dll
NuGet Package : DevExpress.Web.Dashboard.Common
string AddDashboard(
XDocument dashboard,
string dashboardName
)
Function AddDashboard(
dashboard As XDocument,
dashboardName As String
) As String
| Name | Type | Description |
|---|---|---|
| dashboard | XDocument |
A XDocument object that is the XML definition of the dashboard to be added.
| | dashboardName | String |
A String value that specifies the dashboard name.
|
| Type | Description |
|---|---|
| String |
A String that is the identifier of the newly added dashboard.
|
Implement the IEditableDashboardStorage.AddDashboard method to save a dashboard to 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 AddDashboard method is used to save a dashboard definition and its caption to the data storage. The method returns the ID of the new saved dashboard.
public string AddDashboard(XDocument document, string dashboardName) {
using (SqlConnection connection = new SqlConnection(connectionString)) {
connection.Open();
MemoryStream stream = new MemoryStream();
document.Save(stream);
stream.Position = 0;
SqlCommand InsertCommand = new SqlCommand(
"INSERT INTO Dashboards (Dashboard, Caption) " +
"output INSERTED.ID " +
"VALUES (@Dashboard, @Caption)");
InsertCommand.Parameters.Add("Caption", SqlDbType.NVarChar).Value = dashboardName;
InsertCommand.Parameters.Add("Dashboard", SqlDbType.VarBinary).Value = stream.ToArray();
InsertCommand.Connection = connection;
string ID = InsertCommand.ExecuteScalar().ToString();
connection.Close();
return ID;
}
}
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
IEditableDashboardStorage Interface