第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 列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
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[8].Text = i.tostring();
}
gridview类似
否则就在rowbound中计算.
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
===================
我的是 AspNetPager分页,采用存储过程分页,比如我要统计第2页,第2页只有2条(如何根据分页得到这页条数?),那么如何写那么你的返回的记录就是pagesize条,那么用datatable的compunt功能就可(如果是数值) ==================================================
高手,请问这个方法如何写,