I have datatable like this
| Project Name | Source | Source Amount
A Abc $10000
B Xyz $12990
C Mnf $10000
A Dqe $50200
B Pgp $14000
A Rsy $27000
and I need to group by rows for sub total totals in between as
| Project Name | Source | Source Amount
A Abc $10000
A Dqe $50200
A Rsy $27000
Total of A $87200
B Xyz $12990
B Pgp $14000
Total of B $26990
C Mnf $10000
Total of C $10000
All Total $124190
I used groupBy and sum in lambda but couldnot figureout how to include a new row in the existing datatable from withing the lambda expression.
Code I was using like
dt.AsEnumerable()
.GroupBy(d => d.Field<string>("Project Name"))
.Sum(d=>d.Field<string>("Source Amount"))