using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using System.Collections.Generic;

public partial class Default : System.Web.UI.Page
{
    double currentSum = 0;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void MasterTableView_DataBinding(object sender, EventArgs e)
    {
        GridNumericColumn unitPriceCol = RadGrid1.MasterTableView.GetColumnSafe("Freight") as GridNumericColumn;
        unitPriceCol.FooterAggregateFormatString = unitPriceCol.Aggregate.ToString() + ": {0:C}";
    }

    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "RowClick")
        {
            foreach (GridDataItem dataItem in RadGrid1.SelectedItems)
            {
                currentSum += double.Parse(dataItem["Freight"].Text);
            }
            RadGrid1.Rebind();
        }
    }

    protected void RadGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e)
    {
        e.Result = currentSum;
    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        foreach (GridDataItem dataItem in RadGrid1.SelectedItems)
        {
            dataItem.Selected = false;
        }
    }
}
