Reputation: 4305
There are three columns in the datatable
Amount Commission Others
1000 200 100
2000 100 200
Now I want to build another column based on these three columns name totalAmount
that is the sum of these three columns like the column will be
totalAmount
1300
2300
I got the records of the three columns Amount,Commission and Others
and based on those columns I have a need of adding a new column in that datatable.We can manuall fetch and make total and add a new column in that datatable but is there any other good and short way ?
Upvotes: 1
Views: 561
Reputation: 204289
Check out the DataColumn.Expression property.
You can add a new DataColumn to your table, and set its Expression to "Amount + Commission + Others". It'll be calculated at runtime.
Upvotes: 2