Reputation: 5738
How to sum each column value and to display the total sum value in Total Column for the below data using LINQ. SUM should not round the resultant.
Location FY_Quarter .NET java SAP Total
Bangalore Q3 40 60 40 140
Bangalore Q4 50 80 30
Bangalore Q1 70 50 40
Bangalore Q2 30 90 50
Chennai Q3 80 40 60
Chennai Q4 45 50 35
Chennai Q1 60 75 65
Chennai Q2 55 35 90
Example for
Bangalore Q4 50 80 30 160
Under Total
it should show the value as 160
How to get??
Upvotes: 0
Views: 1550
Reputation: 14411
The Total column shouldn't already be in the table itself. This could lead to all sorts of incorrect data.
You should either be looking at programmatically totalling the values in your LINQ/C# code or creating a view which has the Total as a calculated column.
Upvotes: 0
Reputation: 292385
Use a calculated column:
table.Columns.Add("Total", typeof(int), "[.NET] + java + SAP");
Upvotes: 4