第1页
列1  列2 列3
e     2   g
r     e    h
1     e    3
第2页
列1  列2  列3
a    b    c
a     f    e我的需求是:比如当前在GridView的第一页,我想根据GridView这页(第1页)的有多少行循环把GridView某列(列3)读取出来,结果是输出 g+h+3,如果是第2页c+3

解决方案 »

  1.   

    GridView中有个属性showfooter,把这个属性射为true,就可以在数据显示完之后在最下面显示一行。然后你在代码里写计算合计,在rowdatabound里写合计。
      

  2.   

    比如第三列是1,2,3.你就可以定义一个变量,int i+=int32.parse(e.row.cells[3].text)
    if (e.Row.RowType == DataControlRowType.Footer) 
                {
                   
                    e.Row.Cells[8].Text = i.tostring();
    }
      

  3.   

    给个datagrid例子!
    gridview类似
      

  4.   

    http://www.cnblogs.com/downmoon/articles/1018433.html
      

  5.   

    你这个gridview是怎么分的页?如果是用存储过程分页,那么你的返回的记录就是pagesize条,那么用datatable的compunt功能就可(如果是数值)
    否则就在rowbound中计算.
      

  6.   


            string sTotal = "";
            protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {            if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    sTotal += e.Row.Cells[2].Text + " ";//如果是数值型就转换成数值型求和,这里是string连接
                }
                else if (e.Row.RowType == DataControlRowType.Footer)
                {
                    e.Row.Cells[0].Text = sTotal;
                }
            }同时如ls所说,要把ShowFooter设为true
      

  7.   

    你这个gridview是怎么分的页?如果是用存储过程分页,那么你的返回的记录就是pagesize条,那么用datatable的compunt功能就可(如果是数值) 
    ===================
    我的是 AspNetPager分页,采用存储过程分页,比如我要统计第2页,第2页只有2条(如何根据分页得到这页条数?),那么如何写那么你的返回的记录就是pagesize条,那么用datatable的compunt功能就可(如果是数值) ==================================================
     高手,请问这个方法如何写,
      

  8.   

    请问downmoon 你的那个网址,统计出来是所有的数据吗,如何我只计算第2页,如何写