Work with multiple selected items from a ListBox

Discussion in 'ASP .Net' started by Ryan Ternier, Oct 27, 2005.

  1. Ryan Ternier

    Ryan Ternier Guest

    I'm having an issue with a listbox.

    I want to allow users to multi select items in a list box, click a button
    and have them moved somewhere else.

    This works fine for the the first 2 tries. However, a user also has the
    ability to add these items back to the listbox (with the same value and
    Text).

    The new Items get moved to the bottom of the list box.

    It works fine to a point, however, once I move over all items, and move 5
    back, if I select all 5, it will only notice that 3 of them are
    selected.though all 5 are. 2 Will be left, so when I select those 2, it will
    only move 1.

    Any help would be great.

    here's my code:
    --------------------------------------------------------------------------------


    System.Collections.ArrayList arlTemp = new System.Collections.ArrayList();
    foreach(ListItem li in lstAvailHeadings.Items)
    {
    if(li.Selected)
    {
    tblTemp = addSection(tblTemp,Int32.Parse(li.Value),li.Text);
    arlTemp.Add(li.Value);
    }
    }
    BindSections(tblTemp);
    for(int i = 0;i<arlTemp.Count;i++)
    {
    for(int j = 0;j<lstAvailHeadings.Items.Count;j++)
    {
    if(lstAvailHeadings.Items[j].Value == arlTemp.ToString())
    lstAvailHeadings.Items.Remove(lstAvailHeadings.Items[j]);
    }
    }
    arlTemp = null;
    Ryan Ternier, Oct 27, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JP
    Replies:
    2
    Views:
    10,583
  2. Iain
    Replies:
    3
    Views:
    917
  3. K B
    Replies:
    2
    Views:
    654
  4. Jason L Lind

    ListBox Programaticly Set Multiple Items as Selected

    Jason L Lind, Apr 11, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    132
    Jason L Lind
    Apr 11, 2006
  5. Adrian Forbes

    Remove multiple selected items listbox

    Adrian Forbes, Aug 7, 2003, in forum: ASP General
    Replies:
    0
    Views:
    120
    Adrian Forbes
    Aug 7, 2003
Loading...

Share This Page