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;
}
}
{
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;
}
}