Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > listbox add/remove items

Reply
Thread Tools

listbox add/remove items

 
 
KB
Guest
Posts: n/a
 
      02-15-2005
language: c#

ok this has been driving me crazy for too long now!!!

on my page i have 2 listboxes along with an add button and a remove button

the idea is i can add items from listbox1 into listbox2 and i can remove
items from listbox2 only

listbox1 is populated from my database which contains a list of cars

on clicking the add button, the value from the selected item in listbox1 is
inserted into a new table, which in turn populates listbox2, which all works
fine

but when you click the add button i want the selected item from listbox1 to
be removed from listbox1, but i need this to be the case when the user
leaves the page & then comes page

so what iam thinking is:

when the page loads,
- loop through listbox2
- get item[i] in listbox2
- look at listbox1 and remove the matching item

--------------------------------------------------------------------------------------------------
CODE:

//if !Page.IsPostBack

for(int i=0; i<listbox2.Items.Count; i++)

{


string vSel = listbox2.Items[i].Text;

listbox1.Items.Remove(listbox1.Items.FindByText(vS el).ToString());




}

just starting c#, any help much appriciated






 
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
copy ListBox items to anoher listbox Tomas ASP .Net 1 08-12-2008 08:22 AM
unable to retrieve listbox items on postback , items moved usingjavascript between 2 list boxes (source and target ) divya ASP .Net 1 05-28-2008 05:27 AM
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
add items from one listbox to other listbox from javascript mc Javascript 0 12-02-2003 08:23 PM



Advertisments