Hi,
I have tried the following code to replicate your scenario and it worked as expected on my end.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem dataItem = e.Item
as
GridDataItem;
GridGroupByExpression exp =
new
GridGroupByExpression();
GridGroupByField expfield =
new
GridGroupByField();
expfield =
new
GridGroupByField();
expfield.FieldName =
"OrderID"
;
expfield.HeaderText =
"Order count "
;
expfield.FormatString =
"<strong>{0:0.00}</strong>"
;
expfield.Aggregate = GridAggregateFunction.Count;
exp.SelectFields.Add(expfield);
expfield =
new
GridGroupByField();
expfield.FieldName =
"Discount"
;
exp.GroupByFields.Add(expfield);
this
.RadGrid1.MasterTableView.GroupByExpressions.Add(exp);
int
fieldValue =
int
.Parse(dataItem[
"OrderID"
].Text);
total += fieldValue;
}
if
(e.Item
is
GridGroupFooterItem)
{
GridGroupFooterItem itm = e.Item
as
GridGroupFooterItem;
itm[
"OrderID"
].Text =
"Total :"
+ total.ToString();
total = 0;
}
}
Hope this will help.
Thanks,
Princy.