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 do I set a Dropdown list item Programatically?

How do I set a Dropdown list item Programatically?

Scheduled Pinned Locked Moved ASP.NET
questionsalescsharpasp-netdatabase
2 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.
  • Q Offline
    Q Offline
    Quecumber256
    wrote on last edited by
    #1

    I have the following database table. This is a list of department names. DeptID Department 1 Administration 2 Information Technology 3 Product Development 4 Sales 5 Marketing 6 Partnerships 7 Contractor From the Employees table I read in this record: 1001 7 4 Doe Jane M 12/24/2005 12:00:00 AM False My problem is this: I’m using a web page to edit employee information. On this web form there are four drop down boxes, one each for Departments, Titles, Address Types and States. After I initialize the web page and populate the above mentioned drop down list with the necessary data. I want to take the employee record and set the drop down list to the right item in the list. How can I make ASP.NET populate the dropdown lists based on the foreign ID number contained in the employee record? I have a screen shot of what I want the data to look like in the web page, but I can't show it in this message. Thank you, Quecumber256

    D 1 Reply Last reply
    0
    • Q Quecumber256

      I have the following database table. This is a list of department names. DeptID Department 1 Administration 2 Information Technology 3 Product Development 4 Sales 5 Marketing 6 Partnerships 7 Contractor From the Employees table I read in this record: 1001 7 4 Doe Jane M 12/24/2005 12:00:00 AM False My problem is this: I’m using a web page to edit employee information. On this web form there are four drop down boxes, one each for Departments, Titles, Address Types and States. After I initialize the web page and populate the above mentioned drop down list with the necessary data. I want to take the employee record and set the drop down list to the right item in the list. How can I make ASP.NET populate the dropdown lists based on the foreign ID number contained in the employee record? I have a screen shot of what I want the data to look like in the web page, but I can't show it in this message. Thank you, Quecumber256

      D Offline
      D Offline
      Dr_X
      wrote on last edited by
      #2

      listControl.SelectedIndex = listControl.Items.IndexOf(listControl.Items.FindByValue(deptID))

      Michael

      I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

      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