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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. DropDownlist backwards

DropDownlist backwards

Scheduled Pinned Locked Moved ASP.NET
learningdatabasehelpquestion
4 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.
  • B Offline
    B Offline
    Britney S Morales
    wrote on last edited by
    #1

    It look like beginner problem but i couldnt solve it dropdownlist with three members MEMBERS -- VALUES -- INDEX City 1 ---- a -------- 0 City 2 ---- b -------- 1 City 3 ---- c -------- 2 How i could obtain the index, if i know the value or the string Member?? :rose:

    keep Learning and you never will be out of date...

    S M 2 Replies Last reply
    0
    • B Britney S Morales

      It look like beginner problem but i couldnt solve it dropdownlist with three members MEMBERS -- VALUES -- INDEX City 1 ---- a -------- 0 City 2 ---- b -------- 1 City 3 ---- c -------- 2 How i could obtain the index, if i know the value or the string Member?? :rose:

      keep Learning and you never will be out of date...

      S Offline
      S Offline
      sundar156
      wrote on last edited by
      #2

      Hi For this you could use a for loop to check the index of the selected text. like private void DropDownList1_SelectedIndexChanged(.. , ..) { string val=DropDownList1.SelectedItem.Value ; int index=0; for(int i=0;i< DropDownList1.Items.Count;i++) { if(val == DropDownList1.Items[i].Value) index= i; } } I hope this solves the problem.

      Luck is Opportunity with hardwork

      M 1 Reply Last reply
      0
      • S sundar156

        Hi For this you could use a for loop to check the index of the selected text. like private void DropDownList1_SelectedIndexChanged(.. , ..) { string val=DropDownList1.SelectedItem.Value ; int index=0; for(int i=0;i< DropDownList1.Items.Count;i++) { if(val == DropDownList1.Items[i].Value) index= i; } } I hope this solves the problem.

        Luck is Opportunity with hardwork

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

        Simply use DropDownList.SelectedIndex [^]

        1 Reply Last reply
        0
        • B Britney S Morales

          It look like beginner problem but i couldnt solve it dropdownlist with three members MEMBERS -- VALUES -- INDEX City 1 ---- a -------- 0 City 2 ---- b -------- 1 City 3 ---- c -------- 2 How i could obtain the index, if i know the value or the string Member?? :rose:

          keep Learning and you never will be out of date...

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

          Basically, if you want to determine the index of a particular item, you can walk through the Items collection of the dropdownlist to the trick, and for the selected item you can simply use SelectedIndex property.

          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