<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPxDashboard.Default" %>
<%@ Register Assembly="DevExpress.Dashboard.v17.1.Web, Version=17.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function UpdateWidget(s, e) {
if (e.ItemName == 'pieDashboardItem1') {
var pies = e.GetWidget();
var data = s.GetItemData(e.ItemName);
var measure = data.GetMeasures()[0];
$.each(pies, function (_, pie) {
var axisPoint = pie.option('tag').axisPoint;
var total = data.GetSlice(axisPoint).GetMeasureValue(measure.Id).GetDisplayText();
var title = pie.option('title')
if (!title.hasTotal) {
title.text += ' ' + total;
title.hasTotal = true;
pie.option('title', title);
}
});
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxDashboard ID="ASPxDashboard1" runat="server" DashboardStorageFolder="~/App_Data/Dashboards/" WorkingMode="ViewerOnly" LimitVisibleDataMode="Designer"
OnConfigureDataConnection="ASPxDashboard1_ConfigureDataConnection" OnConfigureItemDataCalculation="ASPxDashboard1_ConfigureItemDataCalculation">
<ClientSideEvents ItemWidgetCreated="UpdateWidget" ItemWidgetUpdated="UpdateWidget" />
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>
using DevExpress.DataAccess.ConnectionParameters;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPxDashboard {
public partial class Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxDashboard1_ConfigureDataConnection(object sender, DevExpress.DashboardWeb.ConfigureDataConnectionWebEventArgs e) {
MsSqlConnectionParameters cp = e.ConnectionParameters as MsSqlConnectionParameters;
if (cp != null && cp.DatabaseName == "Northwind") {
cp.AuthorizationType = MsSqlAuthorizationType.SqlServer;
cp.ServerName = ".\\sql2016";
cp.UserName = "Semicolon";
cp.Password = "semicolon;";
string connString = "Server=.\\sql2016;Database=Northwind;User Id=Semicolon;Password=\"semicolon;\";";
string query = "select * from Invoices";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dataTable = new DataTable();
da.Fill(dataTable);
conn.Close();
da.Dispose();
}
}
protected void ASPxDashboard1_ConfigureItemDataCalculation(object sender, DevExpress.DashboardWeb.ConfigureItemDataCalculationWebEventArgs e) {
e.CalculateAllTotals = true;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using DevExpress.Web;
namespace ASPxDashboard {
public class Global_asax : System.Web.HttpApplication {
void Application_Start(object sender, EventArgs e) {
DevExpress.Web.ASPxWebControl.CallbackError += new EventHandler(Application_Error);
}
void Application_End(object sender, EventArgs e) {
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e) {
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e) {
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e) {
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
}
}
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="ASPxDashboard.Default" %>
<%@ Register Assembly="DevExpress.Dashboard.v17.1.Web, Version=17.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function UpdateWidget(s, e) {
if (e.ItemName == 'pieDashboardItem1') {
var pies = e.GetWidget();
var data = s.GetItemData(e.ItemName);
var measure = data.GetMeasures()[0];
$.each(pies, function (_, pie) {
var axisPoint = pie.option('tag').axisPoint;
var total = data.GetSlice(axisPoint).GetMeasureValue(measure.Id).GetDisplayText();
var title = pie.option('title')
if (!title.hasTotal) {
title.text += ' ' + total;
title.hasTotal = true;
pie.option('title', title);
}
});
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxDashboard ID="ASPxDashboard1" runat="server" DashboardStorageFolder="~/App_Data/Dashboards/" WorkingMode="ViewerOnly" LimitVisibleDataMode="Designer"
OnConfigureDataConnection="ASPxDashboard1_ConfigureDataConnection" OnConfigureItemDataCalculation="ASPxDashboard1_ConfigureItemDataCalculation">
<ClientSideEvents ItemWidgetCreated="UpdateWidget" ItemWidgetUpdated="UpdateWidget" />
</dx:ASPxDashboard>
</div>
</form>
</body>
</html>
Imports DevExpress.DataAccess.ConnectionParameters
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace ASPxDashboard
Partial Public Class [Default]
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub ASPxDashboard1_ConfigureDataConnection(ByVal sender As Object, ByVal e As DevExpress.DashboardWeb.ConfigureDataConnectionWebEventArgs)
Dim cp As MsSqlConnectionParameters = TryCast(e.ConnectionParameters, MsSqlConnectionParameters)
If cp IsNot Nothing AndAlso cp.DatabaseName = "Northwind" Then
cp.AuthorizationType = MsSqlAuthorizationType.SqlServer
cp.ServerName = ".\sql2016"
cp.UserName = "Semicolon"
cp.Password = "semicolon;"
Dim connString As String = "Server=.\sql2016;Database=Northwind;User Id=Semicolon;Password=""semicolon;"";"
Dim query As String = "select * from Invoices"
Dim conn As New SqlConnection(connString)
Dim cmd As New SqlCommand(query, conn)
conn.Open()
Dim da As New SqlDataAdapter(cmd)
Dim dataTable As New DataTable()
da.Fill(dataTable)
conn.Close()
da.Dispose()
End If
End Sub
Protected Sub ASPxDashboard1_ConfigureItemDataCalculation(ByVal sender As Object, ByVal e As DevExpress.DashboardWeb.ConfigureItemDataCalculationWebEventArgs)
e.CalculateAllTotals = True
End Sub
End Class
End Namespace
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.SessionState
Imports DevExpress.Web
Namespace ASPxDashboard
Public Class Global_asax
Inherits System.Web.HttpApplication
Private Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
AddHandler DevExpress.Web.ASPxWebControl.CallbackError, AddressOf Application_Error
End Sub
Private Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub
Private Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Private Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub
Private Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
End Sub
End Class
End Namespace