public void GroupRows(GridView grd,int CellsNum) { int i = 0; int rowspan = 1; while(i<grd.Rows.Count-1) { GridViewRow row=grd.Rows[i]; for (++i; i < grd.Rows.Count; i++) { GridViewRow rowNext=grd.Rows[i]; if (row.Cells[CellsNum].Text == rowNext.Cells[CellsNum].Text) { rowNext.Cells[CellsNum].Visible = false; rowspan++; } else { row.Cells[CellsNum].RowSpan = rowspan; rowspan = 1; break; } if (i == grd.Rows.Count - 1) { row.Cells[CellsNum].RowSpan = rowspan; } } } }