应付费用 实付费用 其它费用  这是GridView中的三个字段。可以不在GridView 中增加一行用来显示汇总的钱数。我只要三个费用的总数就行!

解决方案 »

  1.   

    这好办啊,直接在绑定之前,你取出数据,在内存里面直接row.add()加一行,并且计算出数值填充进去,然后再绑定就可以了
      

  2.   


        protected void gvwInfo_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // 合计
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView myrows = (DataRowView)e.Row.DataItem;
                num1 += Convert.ToInt32(myrows[2].ToString());
                num2 += Convert.ToInt32(myrows[3].ToString());
                num3 += Convert.ToInt32(myrows[4].ToString());
                num4 += Convert.ToInt32(myrows[5].ToString());
                num5 += Convert.ToInt32(myrows[6].ToString());
                num6 += Convert.ToInt32(myrows[7].ToString());
                num7 += Convert.ToInt32(myrows[8].ToString());
            }
            // 合计
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "合计";
                e.Row.Cells[1].Text = @"<asp:LinkButton ID='link1'  OnClick='link1_Click'  runat='server'>"+num1.ToString()+"</asp:LinkButton>";
                e.Row.Cells[2].Text = "<a href='htddtp://www.sohu.com' > "+num2.ToString()+"<a/>";
                e.Row.Cells[3].Text = num3.ToString();
                e.Row.Cells[4].Text = num4.ToString();
                e.Row.Cells[5].Text = num5.ToString();
                e.Row.Cells[6].Text = num6.ToString();
                e.Row.Cells[7].Text = num7.ToString(); 
            }
        }
      

  3.   

    怎么数都 是固定 的呀....我不知道有多少行呀!!!
    --------------------------------
    看不懂,michaelowenii 的是可以的,建议你,在查询数据的时候就将汇总这项工作完成,而不是留在 UI 上处理