HtmlSelect control not showing ListItems

G

Guest

Hello All,

I am populating an HtmlSelect control's Items property with four list items.
The HtmlSelect control is contained in a user control which is dropped into
a placeholder on the web form. When the page is rendered, the control is
empty. Here is the code:

In the web form:

Dim UControl As AugmentedDropDownList =
CType(LoadControl("../UserControls/AugmentedDropDownList.ascx"),
AugmentedDropDownList)

UControl.PopulateDropDownList(Control.Attributes("name").Value, DropDownNode)

plcContent.Controls.Add(UControl)

and in the user control:

Public Sub PopulateDropDownList(ByVal ListCaption As String, ByVal
ListItems As XmlNode)
Label1.Text = ListCaption
SelectList = New HtmlSelect
SelectList.Name = ListCaption
For Each Item As XmlNode In ListItems.SelectNodes("Items/Item")
Dim li As New ListItem
li.Value = Item.Attributes("id").Value
li.Text = Item.Attributes("value").Value
SelectList.Items.Add(li)
Next
SelectList.ID = ListItems.Attributes("id").Value
End Sub

Can anyone see what I'm missing?

TIA,
 
G

Guest

Sorry about the answer i give you

You must add the control the the page.

Page.Controls.Add(SelectList)


David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top