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. listBox selected values

listBox selected values

Scheduled Pinned Locked Moved ASP.NET
questionhelp
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.
  • S Offline
    S Offline
    sajjy
    wrote on last edited by
    #1

    hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this : ListBox1.SelectedValue but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?!

    M P 2 Replies Last reply
    0
    • S sajjy

      hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this : ListBox1.SelectedValue but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?!

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      This should help:

      List<ListItem> LlstSelectedItems = new List<ListItem>();
      for(int LiCount = 0; LiCount < ListBox1.Items.Count; LiCount++)
      {
      if (ListBox1.Items[LiCount].Selected)
      LlstSelectedItems.Add(ListBox1.Items[LiCount]);
      }

      Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      1 Reply Last reply
      0
      • S sajjy

        hi , i have some problem in getting the selected values of my ListBox :doh: i use some code like this : ListBox1.SelectedValue but it just gives me the first selected value ! my list box is in multiple mode and user can select some coises !!! how can i get the whole of selected values without using for cycle ?!

        P Offline
        P Offline
        Prabhakar Parihar
        wrote on last edited by
        #3

        u use now listbox1.selecteditem.text fine sure work now

        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