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. Help with dropdownlist [modified]

Help with dropdownlist [modified]

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

    Hi, Suppose I have pulled out data from a database into a data reader and load the DropDownList as follows.

    Dim ddDR As OdbcDataReader = Nothing
    Dim ddOdbcConnection As New OdbcConnection("server=(local);database=[dbname];user id=username;password=password;connection reset=false;connection lifetime=5;min pool size=1;max pool size=50;")
    Dim ddOdbcCommand As New OdbcCommand("SELECT * FROM TableName", ddOdbcConnection)
    ddOdbcConnection.Open()
    ddDR = ddOdbcCommand.ExecuteReader(CommandBehavior.CloseConnection)
    DropDownList1.DataSource = ddDR
    DropDownList1.DataTextField = "DisplayValueFieldFromDB"
    DropDownList1.DataValueField = "DataValueFieldFromDB"
    DropDownList1.DataBind()

    What I would like to do now is read the Data from the DropDownList. I've read that the values can be retrieved as DropDownList.Items[index] - replace the index with a number, which can go up to the maximum number of data members. I am not sure what the author meant by that could you please explain? Thank you in advance for your help. -- modified at 1:01 Thursday 28th June, 2007

    P 1 Reply Last reply
    0
    • A ASPnoob

      Hi, Suppose I have pulled out data from a database into a data reader and load the DropDownList as follows.

      Dim ddDR As OdbcDataReader = Nothing
      Dim ddOdbcConnection As New OdbcConnection("server=(local);database=[dbname];user id=username;password=password;connection reset=false;connection lifetime=5;min pool size=1;max pool size=50;")
      Dim ddOdbcCommand As New OdbcCommand("SELECT * FROM TableName", ddOdbcConnection)
      ddOdbcConnection.Open()
      ddDR = ddOdbcCommand.ExecuteReader(CommandBehavior.CloseConnection)
      DropDownList1.DataSource = ddDR
      DropDownList1.DataTextField = "DisplayValueFieldFromDB"
      DropDownList1.DataValueField = "DataValueFieldFromDB"
      DropDownList1.DataBind()

      What I would like to do now is read the Data from the DropDownList. I've read that the values can be retrieved as DropDownList.Items[index] - replace the index with a number, which can go up to the maximum number of data members. I am not sure what the author meant by that could you please explain? Thank you in advance for your help. -- modified at 1:01 Thursday 28th June, 2007

      P Offline
      P Offline
      postmaster programmingknowledge com
      wrote on last edited by
      #2

      See if following link has any help http://www.programmingknowledge.com/dataControl.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