using combobox in vb.net

dec21st

Active member
Joined
May 14, 2005
Messages
43
Programming Experience
3-5
in asp.net when i wanna create a listbox with text n values i do it like this:

VB.NET:
			Dim objCommand As New SqlCommand(sqlStatement, sqlConn)
			Dim objReader As SqlDataReader = Nothing

			sqlConn.Open()
			objReader = objCommand.ExecuteReader()

			Dim DS As DataSet
			Dim MyCommand As SqlDataAdapter

			DropDownListRest.DataSource = objReader
			DropDownListRest.DataTextField = "branch"
			DropDownListRest.DataValueField = "restCode"
			DropDownListRest.DataBind()
			sqlConn.Close()

however in vb.net i can't seem to find a way on how to create a combobox that extracts 2 types of data from the db and create it

i just wanna get the id n the name of the object from the database and put it in a listbox. how do i do it? and how do i retrieve the value from the listbox also?
 
The ListBox and ComboBox controls have a DisplayMember property and a ValueMember property. I'm guessing that these correspond to the ASP.NET DataTextField and DataValueField properties respectively.
 
Back
Top