/// <Summary>
/// Merge cells with the same information in a column in the gridview
/// </Summary>
/// <Param name = "gridview1"> table object </param>
/// <Param name = "cellnum"> Number of columns to be merged (calculated from 0) </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;
}
}
}
}
/// <Summary>
/// Merge the cells with the same information in the itemtemplate column in The gridview
/// </Summary>
/// <Param name = "gridview1"> table object </param>
/// <Param name = "cellnum"> Number of columns to be merged (calculated from 0) </param>
/// <Param name = "controlname"> name of the hyperlink object in the table </param>
Public static void grouprowsitem (gridview gridview1, int cellnum, string controlname)
{
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 (Hyperlink) gvr. cells [cellnum]. findcontrol (controlname )). TEXT = (Hyperlink) gvrnext. cells [cellnum]. findcontrol (controlname )). 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;
}
}
}
}
Public static void grouprowsitem (gridview gridview1, int cellnum, string controlname, int [] cellnums)
{
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 (Hyperlink) gvr. cells [cellnum]. findcontrol (controlname )). TEXT = (Hyperlink) gvrnext. cells [cellnum]. findcontrol (controlname )). text)
{
Gvrnext. cells [cellnum]. Visible = false;
For (int row = 0; row <cellnums. length; row ++)
{
Gvrnext. cells [cellnums [row]. Visible = false;
}
Rowspannum ++;
}
Else
{
Gvr. cells [cellnum]. rowspan = rowspannum;
For (int row = 0; row <cellnums. length; row ++)
{
Gvr. cells [cellnums [row]. rowspan = rowspannum;
}
Rowspannum = 1;
Break;
}
If (I = gridview1.rows. Count-1)
{
Gvr. cells [cellnum]. rowspan = rowspannum;
For (int row = 0; row <cellnums. length; row ++)
{
Gvr. cells [cellnums [row]. rowspan = rowspannum;
}
}
}
}
}