- private int sumNum = 0;
- private decimal sumSaleIncome = 0M;
- private decimal sumFaceIncome = 0M;
- private decimal sumProfit = 0M;
- if (e.Item.ItemIndex >= 0) //通过e.Item.ItemIndex方法将Cells中的值循环取出来并将之相加再赋给以上定义的相对应的变量
- {
- sumNum += int.Parse(e.Item.Cells[2].Text.ToString().Trim());//取数量总和
- if (e.Item.Cells[4].Text != " ")//取点成本总和 当== 即为空
- sumSaleIncome += decimal.Parse(e.Item.Cells[4].Text.ToString().Trim());
- if (e.Item.Cells[3].Text != " ")//取点销售收入总和
- sumFaceIncome += decimal.Parse(e.Item.Cells[3].Text.ToString().Trim());
- if (e.Item.Cells[5].Text != " ")//取点利润总和
- sumProfit += decimal.Parse(e.Item.Cells[5].Text.ToString().Trim());
- }
- //在页脚中添加点击量列的总和
- //在此通过e.Item.ItemType方法判断是Header还是Footer
- else if (e.Item.ItemType == ListItemType.Footer)
- {
- e.Item.Cells[1].Text = " 累计销售:";
- e.Item.Cells[2].Text = " <font color=red>" + sumNum.ToString() + "</font>";
- e.Item.Cells[4].Text = " <font color=red>" + sumSaleIncome.ToString() + "</font>";
- e.Item.Cells[3].Text = " <font color=red>" + sumFaceIncome.ToString() + "</font>";
- e.Item.Cells[5].Text = " <font color=red>" + sumProfit.ToString() + "</font>";
- sumNum = 0;
- sumSaleIncome = 0m;
- sumFaceIncome = 0m;
- sumProfit = 0m;
- }
在GridView中新增一行的方法并且新增行的值是GridView原所有列的值的总和
最新推荐文章于 2022-02-22 17:58:38 发布