I am trying to create a more detailed item template for the standard CheckBoxList control. It exposes an ITemplate property called TemplateControl but I wasn't able to find a straightforward resource on how to actually use it. Here's the code I have so far:
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Dim items As New List(Of ListItem)
items.Add(New ListItem() With {.Text = "A", .Value = "1"})
items.Add(New ListItem() With {.Text = "B", .Value = "2"})
items.Add(New ListItem() With {.Text = "C", .Value = "3"})
Dim lst As New CheckBoxList()
Dim tpl As ITemplate = LoadTemplate("~/CustomListItem.ascx")
Dim g As New TemplateControlWrapper()
tpl.InstantiateIn(g)
lst.TemplateControl = g
lst.DataSource = items
lst.DataBind()
Form.Controls.Add(lst)
End Sub
Class TemplateControlWrapper
Inherits UserControl
End Class
It seems to be ignoring the TemplateControl property completely. Any ideas?