Read the data from a DropDownList.

Read data from dropdownlist after list is loaded

Page 1 of 1

0 Replies - 4524 Views - Last Post: 29 June 2007 - 12:29 AM Rate Topic: -----

#1 WebNoob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 16-June 07

Read the data from a DropDownList.

Posted 29 June 2007 - 12:29 AM

Hi, suppose I have loaded my dropdownlist with info from the database using OdbcDataReader. How do I read the data from a DropDownList? I would probably need to pull the data out from the table and store it somewhere first. I'm planning to to use OdbcDataReader to store the data and load the DropDownList with the Display Value as DisplayValueFieldFromDB and Data Value as DataValueFieldFromDB . Then I'm going to read the data from a DropDownList. That is as far as I can get, I'm not sure how to read the data from a DropDownList . Is there a tutorial on how to do that? The following code is what I have thus far. If there is, please point me to it, thank you in advance for your help.

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)
ddDR = ddOdbcCommand.ExecuteReader(Commandbehavior.CloseConnection)

	DropDownList1.DataSource = ddDR
	DropDownList1.DataTextField = "DisplayValueFieldFromDB"
	DropDownList1.DataValueField = "DataValueFieldFromDB"

This post has been edited by WebNoob: 29 June 2007 - 12:43 AM

Is This A Good Question/Topic? 0
  • +

Page 1 of 1