listbox add/remove items

K

KB

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 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.Text;

listbox1.Items.Remove(listbox1.Items.FindByText(vSel).ToString());




}

just starting c#, any help much appriciated
 

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

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top