liucan

博客园 首页 新随笔 联系 订阅 管理
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // add the UnitPrice and QuantityTotal to the running total variables
            orderTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "订货量"));
            outTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "发货量"));
            e.Row.Cells[2].HorizontalAlign = e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
            
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = "总计:";
            // for the Footer, display the running totals
            e.Row.Cells[2].Text = orderTotal.ToString("d");
            e.Row.Cells[3].Text = outTotal.ToString("d");

            e.Row.Cells[2].HorizontalAlign = e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
            e.Row.Font.Bold = true;
        }
    }
posted on 2008-12-13 14:11  liucan  阅读(1216)  评论(0编辑  收藏  举报