Back to Devexpress

ASPxVerticalGrid.GetTotalSummaryValue(ASPxVerticalGridSummaryItem) Method

aspnet-devexpress-dot-web-dot-aspxverticalgrid-dot-gettotalsummaryvalue-x28-devexpress-dot-web-dot-aspxverticalgridsummaryitem-x29.md

latest4.4 KB
Original Source

ASPxVerticalGrid.GetTotalSummaryValue(ASPxVerticalGridSummaryItem) Method

Returns a summary value calculated against all records.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public object GetTotalSummaryValue(
    ASPxVerticalGridSummaryItem item
)
vb
Public Function GetTotalSummaryValue(
    item As ASPxVerticalGridSummaryItem
) As Object

Parameters

NameTypeDescription
itemASPxVerticalGridSummaryItem

An ASPxVerticalGridSummaryItem object that represents the summary item.

|

Returns

TypeDescription
Object

An object which represents the summary value.

|

Remarks

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

aspx
<dx:ASPxVerticalGrid ID="ASPxVerticalGrid1" runat="server" AutoGenerateRows="False" 
                     OnCustomSummaryCalculate="ASPxVerticalGrid1_CustomSummaryCalculate"
                     DataSourceID="SqlDataSource1" KeyFieldName="ProductID">
    <Rows>
        <dx:VerticalGridTextRow FieldName="ProductID" />
        <dx:VerticalGridTextRow FieldName="ProductName" />
        <dx:VerticalGridTextRow FieldName="UnitPrice" />
        <dx:VerticalGridTextRow FieldName="UnitsInStock" />
        <dx:VerticalGridTextRow FieldName="UnitsOnOrder" />
    </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>
csharp
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;
}
vb
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

See Also

Vertical Grid

ASPxVerticalGrid Class

ASPxVerticalGrid Members

DevExpress.Web Namespace