- protected void gv_PreRender(object sender, EventArgs e)
- {
- //处理合并信息
- if (this.gv.Rows.Count <= 1)
- {
- return;
- }
- int[] colGroup = {2,3,4,6};//需要合并行,列的索引号
- foreach (int col in colGroup)
- {
- TableCell oldtc = this.gv.Rows[0].Cells[col];
- oldtc.RowSpan = 0;
- int ItemCount = this.gv.Rows.Count;
- //int gvCount = ItemCount - 1;
- //Count-1 处理最后一行合并
- for (int i = 1; i < ItemCount; i++)
- {
- TableCell tc = this.gv.Rows[i].Cells[col];
- if (tc.Text == oldtc.Text)
- {
- tc.Visible = false;
- if (oldtc.RowSpan == 0)
- {
- oldtc.RowSpan = 1;
- }
- oldtc.RowSpan = oldtc.RowSpan + 1;
- oldtc.VerticalAlign = VerticalAlign.Middle;
- }
- else
- {
- oldtc = tc;
- }
- }
- }
- }