Custom Summary

  • 3 minutes to read

Total summaries and group summaries provide five predefined aggregate functions that allow you to calculate:

  • the number of data rows;
  • the maximum and minimum values;
  • the sum and the average value.

ASPxGridView provides the ASPxGridBase.CustomSummaryCalculate event that enables you to implement a custom summary. For example, custom summaries allow you to calculate summaries against records that meet specific criteria and use multiple data fields in calculations.

Implement Custom Summary

Follow the steps below to implement a custom summary:

The ASPxGridBase.CustomSummaryCalculate event fires for grid data rows in the following cases:

  • Calculate a total summary value: the grid raises this event for each data row.

  • Calculate a group summary value: the grid raises this event for each data row in a group.


Note that the grid raises the ASPxGridBase.CustomSummaryCalculate before and after a row is processed.

The summary calculation consists of three stages:


<dx:ASPxGridView ID="ASPxGridView1" runat="server" OnCustomCallback="ASPxGridView1_CustomCallback" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" ClientInstanceName="grid" Theme="Office365" KeyFieldName="ProductID" OnCustomSummaryCalculate="ASPxGridView1_CustomSummaryCalculate">
        <dx:GridViewCommandColumn SelectAllCheckboxMode="Page" ShowSelectCheckbox="True" VisibleIndex="0">
        <dx:GridViewDataTextColumn FieldName="ProductID" VisibleIndex="1" ReadOnly="True">
            <EditFormSettings Visible="False" />
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="2">
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3">
    <Settings ShowFooter="true" />
        <dx:ASPxSummaryItem SummaryType="Custom" FieldName="UnitPrice" ShowInColumn="UnitPrice" DisplayFormat="Total price for selected products: {0:c}" ValueDisplayFormat="{0}:c" />
<br /> <br />
<dx:ASPxButton ID="ASPxButton4" runat="server" Text="Refresh" AutoPostBack="false" Theme="Office365">
    <ClientSideEvents Click="OnClick" />


Online Demo

ASPxGridView - Export Selected Records