Hi there,
I have a DataTable which contains 3 columns ,
column[0] = quantity
column[1] = unit_price
column[2] = total
I have set the column[2].Expression equals to quantity * unit_price, then i compute it .
Code:
DataTable1.Columns["total"].Expression = "quantity*unit_price";
DataTable1.Compute("Sum(total)", "");
Codes above runs without any problem, i was able to calculate the "total" value and store it in the "total" column
The problem is, i would like to sum up the column "total" of the datatable , for instance : the datatable has 3 products, then i want to calculate the sum of the "total" columns. Normally , this could be done using the same code :
Code:
DataTable1.Compute("Sum(total)", "");
but the "total" column's expression has been changed to "quantity*unit_price" previously....hence "Sum(total)" won't work.
I try to assign the "total" column expression back to "total" , but it returns
the Exception:
Code:
Cannot set Expression property due to circular reference in the expression.
Anyone knows how to solve this ? thanks a lot