Listbox move multiple selected items to second listbox

Discussion in 'ASP .Net' started by K B, Jan 7, 2007.

  1. K B

    K B Guest

    Hi, The following code has been successful for me in the past and i just
    can't figure out where I'm going wrong. When I debug I keep getting the
    two top items as selected even though there are not selected and the
    selected items are ignored. I'm using ASP.NET 2.0 and using two server
    listbox controls. Any help appreciated.
    Kit

    Dim item As ListItem
    Dim check As ListItem
    For Each item In lstSelect.Items
    If item.Selected = True Then
    'check if value already exists in lstTo
    check = lstTo.Items.FindByValue(item.Value)
    If Not check Is Nothing Then
    Exit Sub
    Else
    lstTo.Items.Add(New ListItem(item.Text, item.Value))
    End If
    End If
    Next
     
    K B, Jan 7, 2007
    #1
    1. Advertisements

  2. Your code works just fine here. Maybe a reboot will do you some good.
     
    Alvin Bruney [MVP], Jan 8, 2007
    #2
    1. Advertisements

  3. K B

    K B Guest

    Thanks, Alvin. I'm embarrased to say after HOURs of looking at it, that
    I realized my test database table had duplicate values...thereby
    throwing of the selected items. I hope this posting helps someone else
    some day.

    thanks again,
    kb
     
    K B, Jan 8, 2007
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.