从gridview行获取总金额

时间:2022-02-22 21:24:25

Am having a gridview (C#) ,which contains product name,product price,product code...... At the time of page load i need to get the sum of n rows product price to a label... (no sql database here)... Could any one help me out....

我有一个gridview(C#),其中包含产品名称,产品价格,产品代码......在页面加载时我需要得到n行产品价格的总和到标签...(没有sql这里的数据库)......任何人都可以帮助我....

Thank you...

1 个解决方案

#1


You have to loop through the rows and sum it up. Something like the following:

你必须循环遍历行并总结它。类似于以下内容:

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

#1


You have to loop through the rows and sum it up. Something like the following:

你必须循环遍历行并总结它。类似于以下内容:

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