On yueer's blog, I saw the usage of the GridView multi-Table header, but I lost the sorting function of GV. I changed the code and implemented these two functions at the same time, which is very good.
Background code
Protected void GridView1_RowCreated (object sender, GridViewRowEventArgs e)
{
// Create multiple headers
If (e. Row. RowType = DataControlRowType. Header)
{
Int x = 0; // create a variable to insert the cell directly into the header, instead of clearing the original function.
TableCellCollection tcHeader = e. Row. Cells;
// The first column
TcHeader. AddAt (x, new TableHeaderCell ());
TcHeader [x]. Attributes. Add ("colspan", "5"); // cross-Column
// TcHeader [0]. Attributes. Add ("rowspan", "2"); // cross row
TcHeader [x]. Text = "</th> </tr> <tr>"; // input html to wrap multiple headers
X ++;
.....
// Add css attribute adjustment only in the second column
TcHeader [x]. Attributes. Add ("style", "background-color: LightSteelBlue ");
X ++;
}
}