Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' Put user code to initialize the page
Dim DL as New DataList
Dl. HeaderTemplate = New Createdl (listitemtype.header)
Dl. ItemTemplate = New Createdl (listitemtype.item)
Dl. AlternatingItemTemplate = New Createdl (listitemtype.alternatingitem)
Dl. FooterTemplate = New Createdl (listitemtype.footer)
Dim D as New Data
Dl. DataSource = D.gettree
Dl. DataBind ()
Div1. Controls.Add (DL)
End Sub
Public Class Createdl
Implements ITemplate
Shared itemcount as Integer = 0
Dim Templatetype as ListItemType
Sub New (ByVal type as ListItemType)
Templatetype = Type
End Sub
Sub InstantiateIn (ByVal container as control) Implements Itemplate.instantiatein
Dim LC as New Literal
Select Case Templatetype
Case Listitemtype.header
Lc. Text = "<table border=1><tr><th>items</th></tr>"
Case ListItemType.Item
Lc. Text = "<tr><td>item number:" ' & ItemCount. ToString & "</TD></TR>"
AddHandler LC. DataBinding, AddressOf templatecontrol_databinding
Case ListItemType.AlternatingItem
Lc. Text = "<tr><td Bgcolor=lightblue>item Number:" _
& ItemCount. ToString & "</TD></TR>"
Case Listitemtype.footer
Lc. Text = "</TABLE>"
End Select
Container. Controls.Add (LC)
ItemCount + 1
End Sub
Private Sub templatecontrol_databinding (ByVal sender as Object, _
ByVal e as System.EventArgs)
Dim LC as Literal
LC = CType (sender, Literal)
Dim Container as DataListItem
container = CType (LC. NamingContainer, DataListItem)
Lc. Text &= DataBinder.Eval (container. DataItem, "text")
Lc. Text &= "</TD></TR>"
End Sub
End Class
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