This is a migrated thread and some comments may be shown as answers.

Running Total like a Check Register

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Doug Odegaard
Top achievements
Rank 2
Doug Odegaard asked on 03 Sep 2008, 05:31 PM
Has anyone achieved a running total innately in the RadGrid that acts like a checkbook-register or does it truly need to be a backend cursor operation to achieve this look and feel.  i need to place a "Balance" on the last column that adds-subtracts a value in another column over time.

Thanks in advance.
Doug

1 Answer, 1 is accepted

Sort by
0
Doug Odegaard
Top achievements
Rank 2
answered on 03 Sep 2008, 06:17 PM
Well....I figured it out but here it is if anyone needs it....wire up the ItemDataBound event with a page level variable keeping totals

protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
string payment = dataItem["PaymentAmount"].Text;
decimal fieldValue = decimal.Parse(payment);
total += fieldValue;
dataItem["Balance"].Text = total.ToString();
}
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = e.Item as GridFooterItem;
footerItem["PaymentAmount"].Text = "total: " + total.ToString();
}
}

Tags
Grid
Asked by
Doug Odegaard
Top achievements
Rank 2
Answers by
Doug Odegaard
Top achievements
Rank 2
Share this question
or