62,268
社区成员
发帖
与我相关
我的任务
分享
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>";
}
}
细节问题,下次小心点就好[Quote=引用 4 楼 ojqorc 的回复:]
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();
}