今天本来想求列的和,没想到阴差阳错的把行的和搞出来了,先把求行的和贴出来 随后再贴列的和。

table = doe.GetCommodity_Retail_List_dtl();

   //------------------------------------------------------------//
        table.Columns.Add("Sum", typeof(Int32));                      //增加列
        int sum = 0;
        foreach (DataRow dr in table.Rows)               //循环计算综合
        {
            if (dr["price"].ToString().Length == 0)
                continue;
            sum += int.Parse(dr["price"].ToString());
        }
        foreach (DataRow dr in table.Rows)           //计算后结果赋值给新增的列
        {
            dr["Sum"] = sum;
        }
        //------------------------------------------------------------//

相关文章:

  • 2022-12-23
  • 2021-09-06
  • 2021-06-10
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案