Access listbox on dynamic control

M

Matt

Hello!

I have a user control (ascx) which simply has a couple textboxes and a
listbox... On a page that has a could of them, dynamically created, I am
having a weird problem with the listbox..

There are 2 items in the listbox, however...

Response.Write(CType(MedstarLoginControl.FindControl("lbMedstarFacilities"),
ListBox).Items.Count)

Displays 0

If I do this on the very next line...
CType(MedstarLoginControl.FindControl("lbMedstarFacilities"),
ListBox).SelectedIndex = 1

It does select the second item in the list box....

But if I do this right afterwards....

For Each li As ListItem In
CType(MedstarLoginControl.FindControl("lbMedstarFacilities"), ListBox).Items
Response.Write(li.Text)
Next

Nothing happens, because it still thinks there are no items...... Help!!!!

Thanks,

Matt
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top