gridview最后一行要显示总计,里面的中间几个单元格是合并的,最后3个是合计的数据,请问要怎么弄?

解决方案 »

  1.   

    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e) 
        { 
          if (e.Row.RowIndex >= 0) 
            { 
                sum += Convert.ToDouble(e.Row.Cells[2].Text); 
            }         if (e.Row.RowType == DataControlRowType.Footer) 
            { 
                e.Row.Cells[0].Text = "合计"; 
                e.Row.Cells[1].Text = "" 
                e.Row.Cells[2].Text =""; 
            } 
        }
      

  2.   

      e.Row.Cells[1].ColumnSpan =3;可以合并,但是会把最后两cell挤出去
      

  3.   

    分给一楼好了,虽然不是我要的答案,但是给了我启发.
    测试代码贴下,希望帮到一些人
      if (e.Row.RowType == DataControlRowType.Footer) 
            { 
                e.Row.Cells[0].Text = "合计";
                e.Row.Cells[1].ColumnSpan =3;
                e.Row.Cells[2].Visible = false; 
                e.Row.Cells[3].Visible = false;
            }