protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int total=12;//总金额
if (e.Row.RowType == DataControlRowType.DataRow)
{
total =total+ Convert.ToInt32( DataBinder.Eval(e.Row.DataItem, "ck_total")); }
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "总金额:";
e.Row.Cells[1].Text = total.ToString("c");
}
}
这怎么不行呢???
中间那块直接跳过去没有执行,在gridview中只显示12怎么不能统计呢?/
{
int total=12;//总金额
if (e.Row.RowType == DataControlRowType.DataRow)
{
total =total+ Convert.ToInt32( DataBinder.Eval(e.Row.DataItem, "ck_total")); }
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "总金额:";
e.Row.Cells[1].Text = total.ToString("c");
}
}
这怎么不行呢???
中间那块直接跳过去没有执行,在gridview中只显示12怎么不能统计呢?/
{
int total=12;//总金额
if (e.Row.RowType == DataControlRowType.DataRow)
{
total =total+ Convert.ToInt32(e.Row.Cells["gridview统计的列名"].Text.Trim()));//Cells["gridview统计的列名"]也可以改为Cells[gridview统计的列号] }
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "总金额:";
e.Row.Cells[1].Text = total.ToString("c");
}
}
{
total =total+ Convert.ToInt32(((DataRowView)e.Item.DataItem)["ck_total"]);
}
这样只能计算本页的合计