日期:2014-05-18 浏览次数:20482 次
Decimal mysum4 = 0;Decimal sum2=0; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (!string.IsNullOrEmpty(e.Row.Cells[2].Text.ToString()) && e.Row.Cells[2].Text.ToString() != " ") { sum2 += decimal.Parse(e.Row.Cells[2].Text.ToString()); mysum4 = mysum4 + sum2; } } if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Text = "<span align='center' style='color:red'>合计:</span>"; e.Row.Cells[2].Text = "<span align='center' style='color:red'>" + mysum4.ToString() + "</span>"; } }
if (e.Row.RowIndex >= 0) { string xxx = e.Row.Cells[3].Text; sum += Convert.ToDouble(e.Row.Cells[3].Text); } else if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[2].Text = "总计:"; e.Row.Cells[3].Text = sum.ToString(); }