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. How can I get all values of a ListBox(Multiple selection is ON)

How can I get all values of a ListBox(Multiple selection is ON)

Scheduled Pinned Locked Moved ASP.NET
questioncsharphtmlcareer
4 Posts 2 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.
  • X Offline
    X Offline
    xelios
    wrote on last edited by
    #1

    Hi; I've a list box named "listUsers". User can select multiple vales. How can I get the values of all the fields selected? Waiting for reply.....:(( ------------------------- M. Mohsin Ali Freelance .NET Developer and HTML Integrator

    M 1 Reply Last reply
    0
    • X xelios

      Hi; I've a list box named "listUsers". User can select multiple vales. How can I get the values of all the fields selected? Waiting for reply.....:(( ------------------------- M. Mohsin Ali Freelance .NET Developer and HTML Integrator

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. You can loop through all the ListItem objects contained in your listUsers .Items collection, and test the Selected property of each.

      X 1 Reply Last reply
      0
      • M Mike Ellison

        Hi there. You can loop through all the ListItem objects contained in your listUsers .Items collection, and test the Selected property of each.

        X Offline
        X Offline
        xelios
        wrote on last edited by
        #3

        How can I check the selected property? Can u plz give me a code snippet to do this. Mohsin Ali

        M 1 Reply Last reply
        0
        • X xelios

          How can I check the selected property? Can u plz give me a code snippet to do this. Mohsin Ali

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Hi there. It's not that tough - make sure to look at the MSDN documentation on ListBox... it could go something like this -

          foreach (ListItem item in myListBox.Items)
          {
          if (item.Selected == true)
          {
          //... do something for the selected item...
          }
          }

          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