首页 > Web开发 > 详细

GridView中某一列值的总和(web)

时间:2015-01-11 16:02:29      阅读:403      评论:0      收藏:0      [点我收藏+]

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex >= 0)
        {
            sum += Convert.ToDouble(e.Row.Cells[7].Text);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[5].Text = "总薪水:";
            e.Row.Cells[6].Text = sum.ToString();
            e.Row.Cells[3].Text = "平均薪水:";
            e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString();
        }
        foreach (TableCell tc in e.Row.Cells)
        {
            tc.Attributes["style"] = "border-color:Black";
        }
        if (e.Row.RowIndex != -1)
        {
            int id = GridView1.PageIndex * GridView1.PageSize + e.Row.RowIndex + 1;
            e.Row.Cells[0].Text = id.ToString();
        }
    }

GridView中某一列值的总和(web)

原文:http://www.cnblogs.com/Tmc-Blog/p/4216580.html

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