Solution ):
CopyCode The Code is as follows: // <summary>
/// Merge rows with the same information in a column in the gridview (cell)
/// </Summary>
/// <Param name = "gridview1"> gridview </param>
/// <Param name = "cellnum"> column number </param>
Public static void grouprows (gridview gridview1, int cellnum)
{
Int I = 0, rowspannum = 1;
While (I <gridview1.rows. Count-1)
{
Gridviewrow gvr = gridview1.rows [I];
For (++ I; I <gridview1.rows. Count; I ++)
{
Gridviewrow gvrnext = gridview1.rows [I];
If (gvr. cells [cellnum]. Text = gvrnext. cells [cellnum]. Text)
{
Gvrnext. cells [cellnum]. Visible = false;
Rowspannum ++;
}
Else
{
Gvr. cells [cellnum]. rowspan = rowspannum;
Rowspannum = 1;
Break;
}
If (I = gridview1.rows. Count-1)
{
Gvr. cells [cellnum]. rowspan = rowspannum;
}
}
}
}
If you want to merge multiple columns, you can modify them as appropriate.
A complete life should be forgiveness, tolerance, waiting, and love!