ASPxVerticalGrid.GetTotalSummaryValue(ASPxVerticalGridSummaryItem) Method
Returns a summary value calculated against all records.
Namespace: DevExpress.Web
Assembly:
DevExpress.Web.v20.2.dll
NuGet Package:
DevExpress.Web
Declaration
public object GetTotalSummaryValue(
ASPxVerticalGridSummaryItem item
)
Public Function GetTotalSummaryValue(
item As ASPxVerticalGridSummaryItem
) As Object
Parameters
Returns
Type |
Description |
Object |
An object which represents the summary value.
|
The ASPxVerticalGrid enables you to calculate a total summary that calculates an aggregate function by all records and displays the result in the summary panel. A total summary type is represented by a ASPxVerticalGridSummaryItem object.
Example
View Example
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxVerticalGrid ID="ASPxVerticalGrid1" runat="server" OnCustomSummaryCalculate="ASPxVerticalGrid1_CustomSummaryCalculate" Width="700px" AutoGenerateRows="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
<Rows>
<dx:VerticalGridTextRow FieldName="ProductID" VisibleIndex="0">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="ProductName" VisibleIndex="1">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitPrice" VisibleIndex="2">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitsInStock" VisibleIndex="3">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitsOnOrder" VisibleIndex="4">
</dx:VerticalGridTextRow>
</Rows>
<TotalSummary>
<dx:ASPxVerticalGridSummaryItem SummaryType="Average" FieldName="UnitPrice" />
<dx:ASPxVerticalGridSummaryItem SummaryType="Average" FieldName="UnitsOnOrder" />
<dx:ASPxVerticalGridSummaryItem SummaryType="Custom" DisplayFormat="Average Sum ={0}" />
</TotalSummary>
<Settings ShowSummaryPanel="True" />
<SettingsPager Mode="ShowPager"></SettingsPager>
</dx:ASPxVerticalGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb;Persist Security Info=True" ProviderName="System.Data.OleDb" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock], [UnitsOnOrder] FROM [Products]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ASPxVerticalGrid1_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e)
{
ASPxVerticalGridSummaryItem orderedUnits = (sender as ASPxVerticalGrid).TotalSummary["UnitsOnOrder"];
ASPxVerticalGridSummaryItem averagePrice = (sender as ASPxVerticalGrid).TotalSummary["UnitPrice"];
Int32 intOrderedUnits = Convert.ToInt32(((ASPxVerticalGrid)sender).GetTotalSummaryValue(orderedUnits));
Int32 intAveragePrice = Convert.ToInt32(((ASPxVerticalGrid)sender).GetTotalSummaryValue(averagePrice));
e.TotalValue = intOrderedUnits * intAveragePrice;
}
}
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxVerticalGrid ID="ASPxVerticalGrid1" runat="server" OnCustomSummaryCalculate="ASPxVerticalGrid1_CustomSummaryCalculate" Width="700px" AutoGenerateRows="False" DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
<Rows>
<dx:VerticalGridTextRow FieldName="ProductID" VisibleIndex="0">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="ProductName" VisibleIndex="1">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitPrice" VisibleIndex="2">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitsInStock" VisibleIndex="3">
</dx:VerticalGridTextRow>
<dx:VerticalGridTextRow FieldName="UnitsOnOrder" VisibleIndex="4">
</dx:VerticalGridTextRow>
</Rows>
<TotalSummary>
<dx:ASPxVerticalGridSummaryItem SummaryType="Average" FieldName="UnitPrice" />
<dx:ASPxVerticalGridSummaryItem SummaryType="Average" FieldName="UnitsOnOrder" />
<dx:ASPxVerticalGridSummaryItem SummaryType="Custom" DisplayFormat="Average Sum ={0}" />
</TotalSummary>
<Settings ShowSummaryPanel="True" />
<SettingsPager Mode="ShowPager"></SettingsPager>
</dx:ASPxVerticalGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\nwind.mdb;Persist Security Info=True" ProviderName="System.Data.OleDb" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock], [UnitsOnOrder] FROM [Products]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DevExpress.Web
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 ASPxVerticalGrid1_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs)
Dim orderedUnits As ASPxVerticalGridSummaryItem = (TryCast(sender, ASPxVerticalGrid)).TotalSummary("UnitsOnOrder")
Dim averagePrice As ASPxVerticalGridSummaryItem = (TryCast(sender, ASPxVerticalGrid)).TotalSummary("UnitPrice")
Dim intOrderedUnits As Int32 = Convert.ToInt32(DirectCast(sender, ASPxVerticalGrid).GetTotalSummaryValue(orderedUnits))
Dim intAveragePrice As Int32 = Convert.ToInt32(DirectCast(sender, ASPxVerticalGrid).GetTotalSummaryValue(averagePrice))
e.TotalValue = intOrderedUnits * intAveragePrice
End Sub
End Class
See Also