I want to display group by sum in new column in same data table. For example:
I want output to be like:
I have tried like below:
- group by sno and stored in different table.
- by using for loop, i am assigning total values to old data table.
for (int o = 0; o < returndata.Rows.Count;o++)
{
for (int i = 0; i < table.Rows.Count;i++)
{
if(returndata.Rows[o]["sno"].ToString() == table.Rows[i]["sno"].ToString())
{
table.Rows[i]["total"] = returndata.Rows[o]["total"];
}
}
}
Is there any other way to directly assign sum values using c# linq?