Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to start a multiple column dropdownlist with what already there

Status
Not open for further replies.

Rexxx

MIS
Oct 16, 2001
47
0
0
Below I have an array that populates a dropdown list box and inserts, as a first item of the array, that item of the array which is already part of the record which the user will then either leave as is or select another item in the array to change:

Dim selectCMD7 As SqlCommand = New SqlCommand()
Dim data7 as SqlDataReader
selectCMD7.CommandText = "Select coname From org where orgtype = 'Fund'"
selectCMD7.Connection = dbconn1
selectCMD7.CommandTimeout = 30
dbconn1.Open()
data7 = selectCMD7.ExecuteReader()
Dim fund1array as ArrayList
fund1array = new ArrayList()
fund1array.add("")
Do while data7.read()
fund1array.add(data7("coname"))
loop
dbconn1.close()
fund1array.Insert(0, coDS.tables("company").Rows(0).Item("fund"))
fund1.DataSource = fund1array
fund1.DataBind()

Below is similar to above but combining three different columns together and displaying as such in the dropdown list box:

Dim selectCMD As SqlCommand = New SqlCommand()
selectCMD.CommandText = "Select lname, lname + ' ' + fname + ' ' + mname As firstmiddlelast, id From people order by lname"
selectCMD.Connection = dbconn1
selectCMD.CommandTimeout = 30
dbconn1.Open()
name1.DataSource = selectCMD.ExecuteReader()
name1.DataTextField = "firstmiddlelast"
name1.DataValueField = "id"
name1.DataBind()
dbconn1.Close()

Question is how to have this dropdown list begin with what is already in the record? The record contains the three database columns (i.e., lname, fname, mname) and corresponding value column (i.e., id).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top