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. Watch out !!! a bug in DropDownList

Watch out !!! a bug in DropDownList

Scheduled Pinned Locked Moved ASP.NET
databasedata-structureshelp
3 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.
  • I Offline
    I Offline
    israeli
    wrote on last edited by
    #1

    Hi, I wanted to highlight a bug in the Web-Control DropDownList. If it contains two or more items with different names, but with the same values, then it returns the SelectedIndex of the first item in the items array with the common value rather then the index of the chosen item. Bye

    M 1 Reply Last reply
    0
    • I israeli

      Hi, I wanted to highlight a bug in the Web-Control DropDownList. If it contains two or more items with different names, but with the same values, then it returns the SelectedIndex of the first item in the items array with the common value rather then the index of the chosen item. Bye

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, I don't think this is a bug. As you may already know that the dropdownlist control at the client side is the select html element, when you submit the page, the value (not the text) of the selected option item of the select element is posted to the server. And at the server side, the SelectedIndex property is set to the index of the item which is first found in the collection of the control based on the Value property, not the Text property. So if there are more than one item that have the same value, you'll see that the first item in the collection is selected.

      I 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, I don't think this is a bug. As you may already know that the dropdownlist control at the client side is the select html element, when you submit the page, the value (not the text) of the selected option item of the select element is posted to the server. And at the server side, the SelectedIndex property is set to the index of the item which is first found in the collection of the control based on the Value property, not the Text property. So if there are more than one item that have the same value, you'll see that the first item in the collection is selected.

        I Offline
        I Offline
        israeli
        wrote on last edited by
        #3

        I disagree with you this time. Indeed you describe the procedure that happens. But I thought that ASP.NET should be Object Oriented. As far as I understand by a straightforward thinking, the SelectedIndex property should be as it sounds like, the index of the selected item. Apparently, the items are being represented to the user by the text property, not the values properties. Bye

        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