Telerik RadGrid provides a method to define aggregates on a per column basis from design time and render the results inside the respective column's footer. Aggregate calculations are supported for GridBoundColumns and GridCalculatedColumns.
Steps:-
--Subscribe to the your DataBound event of Grid
--Iterate through the rows in the underlying grid source
--Sum up the total and insert it in the respective column footer
aspx-
<telerik:RadGrid ID="RG1" runat="server">
<MasterTableView AutoGenerateColumns="False" ShowFooter="True" AllowPaging="true">
<FooterStyle BackColor="#cc6633"></FooterStyle>
<Columns>
<telerik:GridBoundColumn HeaderText="Item Count" DataField="Item Count" UniqueName="Item Count" />
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>
in C#-
private void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
int fieldValue = int.Parse(dataItem["Item Count"].Text);
total = total + fieldValue;
}
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
footerItem["Item Count"].Text = "Total: " + total.ToString();
}
}
protected void RadGrid1_DataBound(object sender, System.EventArgs e)
{
DataTable gridTable = GetDataTable("SELECT * FROM [Order Details]");
foreach (DataRow row in gridTable.Rows)
{
grandTotal = grandTotal + int.Parse(row["Quantity"]);
}
GridFooterItem footerItem = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0];
footerItem["Item Count"].Text = footerItem["Item Count"].Text + "<br> Total for all pages: " + grandTotal.ToString();
}