First look at the following table:
Salesist area Beijing, Shanghai, China, Zhang San 100200300, China
In fact, the DataGrid under ASP.NET is just a htmltable, but only adds a lot of attributes, methods, and incorporates the ViewState mechanism on the basis of HTMLTABLE, to generate, control it; there is this understanding, things are very good. :
We can define the header of the column in the property generator, which actually only insert " TD>
Salesist area Beijing, Shanghai, China
But it is obviously not enough, because we also need a line, the column merge
We can handle it in the DataGrid ItemDATABOUND event
IF (E.Item.ItemType == ListItemType.Header) {E.Item.cells [0] .ROWSPAN = 2; E.Item.cells [1] .Columnspan = 3; E.Item.cells [2] .visible = false; E.Item.cells [3] .visible = false;