首页 > 其他 > 详细

给GridView增加求和行

时间:2015-09-23 16:23:59      阅读:219      评论:0      收藏:0      [点我收藏+]

1、在WebForm窗体中,设置GridView的ShowFooter="True"

2、在后台代码中

private int jhrs=0,ybrs=0;//定义变量

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowIndex >= 0)

{

jhrs += Convert.ToInt16(e.Row.Cells[4].Text);

ybrs += Convert.ToInt16(e.Row.Cells[5].Text);

}

else if (e.Row.RowType == DataControlRowType.Footer)

{

e.Row.Cells[0].Text = "合计";

e.Row.Cells[4].Text = jhrs.ToString();

e.Row.Cells[5].Text = ybrs.ToString();

}

}

技术分享

 

给GridView增加求和行

原文:http://www.cnblogs.com/xusy/p/4832448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!