使用datagrid实现了数据的显示,想把统计行放到Foot里面,如何实现?

解决方案 »

  1.   

    在代码页设置一个变量用于累加。设置gridview的showfooter=true.decimal dclBY;
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                dclBY += decimal.Parse(e.Row.Cells[1].Text);
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[1].Text = dclBY.ToString();
            }
        }