0

Hi- I have 2 list boxes, ListBox1 and ListBox2.

ListBox1's item collection is populated with data from a database.
It populates just fine.

ListBox2 is empty

Let's say ListBox1 has an item "Eric" with a value of "1"

So I can select that item in code by:

ListBox1.SelectedValue = "1"

That works just fine.

Now, I want to go through the items in ListBox1 and any selected item I want to copy to ListBox2.

(in this senario nitem is "1")


ListBox1.SelectedValue = nitem

Dim item As ListItem
For Each item In ListBox1.Items
If item.Selected = True Then
ListBox2.Items.Add(item)
End If
Next

So it selects just fine in ListBox1, but doesn't Add the item to ListBox2.

Any ideas? Thoughts? Suggestions?

1
Contributor
1
Reply
2
Views
9 Years
Discussion Span
Last Post by ericstenson
0

Nevermind. I figured it out. Needed to wait until ListBox1 was fully databound, then call my code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.