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. Putting DB value into a dropdown listbox in a DataGrid

Putting DB value into a dropdown listbox in a DataGrid

Scheduled Pinned Locked Moved ASP.NET
questiondatabasecsshelptutorial
2 Posts 2 Posters 2 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.
  • J Offline
    J Offline
    JohnO3535
    wrote on last edited by
    #1

    I am working with a DataGrid and a Database. What follows is an example of the grid that I want to build (this example works - my question will come after it). I have stripped out most of the properties because they are not relavent to my question. There is an example of building a DataGrid that looks like this... Enabled="false" /> The last column of this grid is a Checkbox. And it is checked or unchecked based on what is in the database. My question is, how can I do something similar with a dropdown listbox? I have a location ID that I want to use to select the correct item in the listbox. But I do not know what property to set to get it to select that item. Here is what I have (but it only selects the first item no matter what the value is in the database)... Arizona Atlanta Cinncinati Washington DC Any help would be greatly appreciated. Johno

    M 1 Reply Last reply
    0
    • J JohnO3535

      I am working with a DataGrid and a Database. What follows is an example of the grid that I want to build (this example works - my question will come after it). I have stripped out most of the properties because they are not relavent to my question. There is an example of building a DataGrid that looks like this... Enabled="false" /> The last column of this grid is a Checkbox. And it is checked or unchecked based on what is in the database. My question is, how can I do something similar with a dropdown listbox? I have a location ID that I want to use to select the correct item in the listbox. But I do not know what property to set to get it to select that item. Here is what I have (but it only selects the first item no matter what the value is in the database)... Arizona Atlanta Cinncinati Washington DC Any help would be greatly appreciated. Johno

      M Offline
      M Offline
      MS le Roux
      wrote on last edited by
      #2

      AFAIK you have to do that in code, by doing something like this: MyDropDownList.Items.FindByValue(MyValue).Selected = True If that doesn't work, you may have to just loop through the items and set the drop-down's SelectedIndex property manually. Here's a useful link: http://aspnet.4guysfromrolla.com/articles/080702-1.3.aspx[^]

      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