Get total price sum from grid rows

Am has a gridview (C #) that contains the product name, product price, product code ...... During page load, I need to get the sum of n rows of product price per label ... (no sql database here) .. .Can anyone help me ...

Thank...

0


source to share


1 answer


You need to iterate over the strings and sum them. Something like the following:



double Total = 0;
foreach(GridViewRow row in MyGridView.Rows)
    Total += Convert.ToDouble(row.Cells[PRICE_COLUMN].Text);

      

+3


source







All Articles