asp.net增加合计行

protected void gvWorkOrder_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow) //检查是否为datarow
{

totalcash += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "cash")); 

totalunbalanced += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "unbalanced")); 
totalsettled += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "settled")); 
} 
else if(e.Row .RowType ==DataControlRowType .Footer ) 
{ 
e.Row.Cells[0].Text = "合计"; 
e.Row.Cells[1].Text = totalcash.ToString("0.00"); 
e.Row.Cells[2].Text = totalunbalanced.ToString("0.00"); 
e.Row.Cells[3].Text = totalsettled.ToString("0.00"); 
e.Row.Font.Bold = true; 
} 

  

            if (e.Row.RowType == DataControlRowType.DataRow) //检查是否为datarow
            {
                //DateTime PlanStart = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "FName")); //取得数据
                //if (PlanStart < DateTime.Parse(txtStartDate.Text))
                //{
                //    e.Row.BackColor = System.Drawing.Color.FromName("#FFCCCC"); //颜色突出显示
                //}
                double totalnum=0;
                double totalMoney=0;
                DataRowView drvBasicCountInfor = (DataRowView)e.Row.DataItem;
                double inum = Convert.ToDouble(drvBasicCountInfor[6].ToString());//6是第5列的数字
                //生成总计
                //totalNumber += iNumber;
                totalnum += inum;
                Double imoney = Convert.ToDouble(drvBasicCountInfor[8].ToString());//6是第5列的数字
                //生成总计
                //totalmoneyNumber += imoneyNumber;
                totalMoney += imoney;

                //e.Row.Cells[0].Text = "总计:";
                //e.Row.Cells[5].Text = string.Format("{0}", totalnum);
                e.Row.Cells[6].Text = string.Format("{0:c}", totalMoney);
                e.Row.Cells[8].Text = string.Format("{0:c}", imoney);
            }

  

转载于:https://www.cnblogs.com/laojiefang/archive/2012/06/04/2533642.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值