listbox add/remove items

Discussion in 'ASP .Net Web Controls' started by KB, Feb 15, 2005.

  1. KB

    KB Guest

    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
     
    KB, Feb 15, 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. kent
    Replies:
    1
    Views:
    894
    Andrew de la Harpe
    May 3, 2004
  2. K B
    Replies:
    2
    Views:
    686
  3. divya
    Replies:
    1
    Views:
    1,106
    Munna
    May 28, 2008
  4. Tomas
    Replies:
    1
    Views:
    585
    Munna
    Aug 12, 2008
  5. mc
    Replies:
    0
    Views:
    246
Loading...

Share This Page