首页 > 其他 > 详细

Gridview 尾部添加总计

时间:2016-03-26 12:24:05      阅读:95      评论:0      收藏:0      [点我收藏+]

1、GridView控件showfooter的属性=true

2、

    int totalZJ, iZJ;
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            Label labId = (Label)e.Row.FindControl("labId");
            labId.Text = (e.Row.RowIndex + 1 + AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1)).ToString();
        }
        if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
        {
            DataRowView drvBasicCountInfor = (DataRowView)e.Row.DataItem;
            iZJ = Convert.ToInt32(drvBasicCountInfor[2]); 
            //生成总计 
            totalZJ += iZJ;
        }
        if (e.Row.RowType == DataControlRowType.Footer)  //页脚 
        {
            e.Row.Cells[3].Text = "学分总计:";  
            e.Row.Cells[3].Style.Add("text-align", "right"); 
            e.Row.Cells[4].Text = string.Format("{0}", totalZJ);
            e.Row.Cells[4].Style.Add("text-align", "center");
        }

    }

  技术分享

Gridview 尾部添加总计

原文:http://www.cnblogs.com/panmy/p/5322498.html

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