c#语言:
if (e.Row.RowIndex >= 0)
        {
        
            sum += Convert.ToDecimal(e.Row.Cells[4].Text);
        }
 else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[3].Text = "所选商品的折后总价为:";
            e.Row.Cells[4].Text = sum.ToString();
            AllPrice = sum;
         } 这个是没有分页前的程序,怎么改在分页后显示总价为多页的总价,成功及给分。谢谢啦

解决方案 »

  1.   

    直接用SQL语句处理了。
    或者你循环页数,分别得到每页的和。放入SESSION或者HiddenFiled或者lable
     最后相加。
      

  2.   

    if (ds2.Tables[0].Rows.Count > 0) 
                { 
                    int total = 0; 
                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) 
                    { 
                        if (ds2.Tables[0].Rows[i]["plan_package"].ToString() != "") 
                        { 
                            total += Convert.ToInt16(ds2.Tables[0].Rows[i]["plan_package"].ToString()); 
                        } 
                    } 
                    this.Label5.Text = "共计: " + total.ToString() + " "; 
                }
      

  3.   

    有分页 就别折腾了吧!~·· 会每页都显示你合计的何  用table 定义表格 对齐gridview列  然后用Label 显示  
    注意table 紧挨着gridview  然后背景色和gridview的接近  显示效果很好。。
    也没必要去折腾 分页的那种显示了。。
      

  4.   

    不管你怎么分页怎么搞,GIRDVIEW2.ROWS[INDEX].CELLS[INDEX].TEXT都可以取到数据!而且都是从0行开是遍历的,你想怎么计算就怎么计算,统计全部就用数据源,统计单页面就针对CELLS去统计!
      

  5.   

    DataTable dt=this.GridView1.Datasouce as DataTable;
    string Sum = dt.Compute("sum(jine)", "true").ToString();
      

  6.   

    我还是在SQL里面做了,谢谢各位了。