Code
decimal totalstock = 0;
protected void GridView2_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
totalstock += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "total"));
// totalstock += DataBinder.Eval(e.Row.DataItem, "total");
//在这里就可以实现总和的计算了
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = "合计:";
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[3].Text = totalstock.ToString();
}
}
decimal totalstock = 0;
protected void GridView2_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
totalstock += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "total"));
// totalstock += DataBinder.Eval(e.Row.DataItem, "total");
//在这里就可以实现总和的计算了
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = "合计:";
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[3].Text = totalstock.ToString();
}
}