请问下Gridview 分页后求值
Gridview分页后求一字段的总和,不想从数据库读取,从Gridview显示的字段去计算,请问下怎么计算啊! --------------------编程问答-------------------- 那就在GridView的FooterTemplate里处理一下就可以了。 --------------------编程问答-------------------- 怎么处理啊!可以给说说吗?谢谢了 --------------------编程问答-------------------- mark --------------------编程问答-------------------- 偶也关注着。 --------------------编程问答-------------------- 怎么没人给说哈啊! --------------------编程问答-------------------- 在RowDataBound事件里 一次相加 --------------------编程问答--------------------获取Rows[index].Cell[]来相加! --------------------编程问答-------------------- 我在 RowDataBound这样写的帮我看看那错了
double a = 0;
for (int i = 0; i < this.GridView1.Rows.Count; i++) {
if (e.Row.Cells[6].Text != null) {
a+= Convert.ToInt16(GridView1.Rows[i].Cells[6].Text.ToString());
}
}
this.number.Text = a.ToString(); --------------------编程问答-------------------- e.Row.Cells[6].Text 是什么意思? --------------------编程问答--------------------
会不会你数格子错了 --------------------编程问答-------------------- 报什么错 你也没贴出来 --------------------编程问答-------------------- 循环读,然后相加得出 --------------------编程问答-------------------- 不知道,关注下 --------------------编程问答-------------------- 好像方法有很多,可以在绑定数据后遍历Grideview
甚至可以用js实现 --------------------编程问答-------------------- 关注中·· --------------------编程问答-------------------- FooterTemplate
循环gridview 把列相加,显示在FooterTemplate 中的label 里
补充:.NET技术 , ASP.NET