Recently I used the DataGrid multi-layer table header. I asked a lot of people and I felt that the answer was not very clear. I summarized it myself and hoped that I would avoid detours for the future developers. Similar to the above situation, at first glance, I thought it was necessary to implement it through table, but I believe that the powerful DataGrid is Is to start searching for methods. Some predecessors explain that tableheadercell is added to tablecellcollection (this should be the foundation Content ). The figure is in the traditional Chinese format. <Asp: DataGrid id = "userdg" onitemcreated = "maid" Public sub datagrid1_itemcreated (byval sender as object, byval e System. Web. UI. webcontrols. datagriditemeventargs) If E. Item. itemtype = listitemtype. header then Dim TCl as tablecellcollection = E. Item. Cells TCL. Clear () TCL. Add (New tableheadercell) TCL (0). rowspan = 2 TCL (0). Text = "personal code" TCL. Add (New tableheadercell) TCL (1). rowspan = 2 TCL (1). Text = "gender" TCL. Add (New tableheadercell) TCL (2). rowspan = 2 TCL (2). Text = "name" TCL. Add (New tableheadercell) TCL (3). rowspan = 2 TCL (3). Text = "service <br> times" TCL. Add (New tableheadercell) TCL (4). rowspan = 2 TCL (4). Text = "User <br> modify" TCL. Add (New tableheadercell) TCL (5). rowspan = 2 TCL (5). Text = "Health <br> List" TCL. Add (New tableheadercell) TCL (6). columnspan = 4 TCL (6). Text = "personal disease risk assessment </TD> <TD colspan = '1' rowspan = '2' align = center Valign = middle bgcolor = '#0082c6'> <font color = '# ffff'> management <br> prescription </font> </TD> <TD Rowspan = '2' align = center valign = middle bgcolor = '#0082c6'> <font color = '# ffff'> summary <br> report </Font> </TD> <TD rowspan = '2' align = center valign = middle bgcolor = '#0082c6'> <font Color = '# ffff'> highlights <br> tip </font> </TD> </tr> <TD bgcolor =' #848284 'align = 'center' Valign = 'ddle'> <font color = '# ffff'> diabetes </font> </TD> <TD bgcolor =' #848284 'align = 'center' Valign = 'midddle'> <font color = '# ffff'> stroke </font> </TD> <TD bgcolor =' #848284 'align = 'center' Valign = 'midddle'> <font color = '# ffff'> Coronary Heart Disease </font> </TD> <TD bgcolor =' #100' Align = 'center' valign = 'middle'> <font color = '# ffff'> lung cancer </font>"
End if End sub 'maid _ itemcreated The key part is TCL. Add (New tableheadercell) TCL (6). columnspan = 4 TCL (6). Text = "personal disease risk assessment </TD> <TD colspan = '1' rowspan = '2' align = center Valign = middle bgcolor = '#0082c6'> <font color = '# ffff'> management <br> prescription </font> </TD> <TD Rowspan = '2' align = center valign = middle bgcolor = '#0082c6'> <font color = '# ffff'> summary <br> report </Font> </TD> <TD rowspan = '2' align = center valign = middle bgcolor = '#0082c6'> <font Color = '# ffff'> highlights <br> tip </font> </TD> </tr> <TD bgcolor =' #848284 'align = 'center' Valign = 'ddle'> <font color = '# ffff'> diabetes </font> </TD> <TD bgcolor =' #848284 'align = 'center' Valign = 'midddle'> <font color = '# ffff'> stroke </font> </TD> <TD bgcolor =' #848284 'align = 'center' Valign = 'midddle'> <font color = '# ffff'> Coronary Heart Disease </font> </TD> <TD bgcolor =' #100' align = 'center' valign = 'middle'> lung cancer " myself the steps are as follows: now the structure is designed in the table, and then the double quotation marks are converted into single quotation marks and added to tableheadercell. text. Multiple complex operations can be implemented. I hope it will be helpful to those who will not use the DataGrid multi-layer header design! |