Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Loop thru ListBox selected items?

Loop thru ListBox selected items?

Scheduled Pinned Locked Moved ASP.NET
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mittalpa
    wrote on last edited by
    #1

    Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---

    J A 2 Replies Last reply
    0
    • M mittalpa

      Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---

      J Offline
      J Offline
      jpribele
      wrote on last edited by
      #2
      protected void Add( object obj, CommandEventArgs args ) {
        ArrayList tmp = new ArrayList();
        for( int i = 0; i < lstBox1.Items.Count;i++ ) {
          if( lstBox1.Items[i].Selected ) {
            lstBox2.Items.Add( listBox1.Items[i] );
            tmp.Add( lstBox1.Items[i] );
          }
        }
        
        for( int i = 0; i 
      

      for the remove change lstBox1 to listBox2 you should have to worry about duplicate because if you remove the items from lstBox1 after added them to lstBox2 you can't add a duplicate no guarentees on this code. i just whipped this up joe

      1 Reply Last reply
      0
      • M mittalpa

        Hi I have two list boxes and two buttons: Add, Remove. Loading the 1st listbox in Page Load. Add button adds those items to 2nd box, which are selected in Ist one. 1. How do I loop through Ist one? 2. Also, I need to check that item is not there in 2nd before adding it. 3. Also, I need to remove it from Ist list box. Please advice. Thanks Follow your goals, Means will follow you ---Gandhi---

        A Offline
        A Offline
        Andy Smith
        wrote on last edited by
        #3

        Check out my free DualList control.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups