{
if (GridView1.Rows.Count <= 1)
{
return;
}
for (int i = 0; i < GridView1.Columns.Count; i++)
{
TableCell oldtc = GridView1.Rows[0].Cells[i];
for (int j = 1; j < GridView1.Rows.Count; j++)
{
TableCell newtc = GridView1.Rows[j].Cells[i];
if (newtc.Text == oldtc.Text)
{
newtc.Visible = false;
if (oldtc.RowSpan == 0)
{
oldtc.RowSpan = 1;
oldtc.RowSpan = oldtc.RowSpan + 1;
oldtc.VerticalAlign = VerticalAlign.Middle;
}
else
{
oldtc = newtc;
}
}
}
}
}