DataGrid multi-layer header design

Source: Internet
Author: User

<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 risk assessment </td> <td colspan = 1 rowspan = 2 align = center

Valign = middle bgcolor = #0082C6> <font color = # ffffff> management <br> prescription </font> </td> <td

Rowspan = 2 align = center valign = middle bgcolor = #0082C6> <font color = # ffffff> summary <br> report

</Font> </td> <td rowspan = 2 align = center valign = middle bgcolor = #0082C6> <font

Color = # ffffff> highlights <br> tips </font> </td> </tr> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> diabetes </font> </td> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> stroke </font> </td> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> Coronary Heart Disease </font> </td> <td bgcolor = #848284

Align = center valign = middle> <font color = # ffffff> lung cancer </font>"

End If
End Sub DataGrid1_ItemCreated
The key part is
Tcl. Add (New TableHeaderCell)
Tcl (6). ColumnSpan = 4
Tcl (6). Text = "personal risk assessment </td> <td colspan = 1 rowspan = 2 align = center

Valign = middle bgcolor = #0082C6> <font color = # ffffff> management <br> prescription </font> </td> <td

Rowspan = 2 align = center valign = middle bgcolor = #0082C6> <font color = # ffffff> summary <br> report

</Font> </td> <td rowspan = 2 align = center valign = middle bgcolor = #0082C6> <font

Color = # ffffff> highlights <br> tips </font> </td> </tr> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> diabetes </font> </td> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> stroke </font> </td> <td bgcolor = #848284 align = center

Valign = middle> <font color = # ffffff> Coronary Heart Disease </font> </td> <td bgcolor = #848284

Align = center valign = middle> <font color = # ffffff> lung cancer </font>"

Now the structure of the Table is designed, and the double quotation marks are converted into single quotation marks, which can be added to TableHeaderCell. text. Multiple complex operations can be implemented.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.