Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Work with multiple selected items from a ListBox

Reply
Thread Tools

Work with multiple selected items from a ListBox

 
 
Ryan Ternier
Guest
Posts: n/a
 
      10-27-2005
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[i].ToString())
lstAvailHeadings.Items.Remove(lstAvailHeadings.Ite ms[j]);
}
}
arlTemp = null;


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
DropDownList 2 always returns Selected = 0 for all items - even selected item Iain ASP .Net 3 12-11-2006 11:07 AM
ListBox Programaticly Set Multiple Items as Selected Jason L Lind ASP .Net Web Controls 0 04-11-2006 10:55 PM
Remove multiple selected items listbox Adrian Forbes ASP General 0 08-07-2003 03:19 PM
Loop through the listbox to read selected items JP ASP .Net 2 07-03-2003 06:29 PM



Advertisments