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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add two fields in a dropdownlist? 1

Status
Not open for further replies.

lunargirrl

Programmer
Jan 26, 2004
77
BR
...
cboUsers.DataSource = ds
cboUsers.DataTextField = "User_Name" & "User_Id"
cboUsers.DataValueField = "User_Name" & "User_Id"
cboUsuarios.DataBind()


I need my dropdownlist to receive 2 fields (User_Name and User_Id, but i get an error, is it possible to do something like that?

Tia,
Gis.
 
You would need to combine them in the query for the datasource. If you don't need to see the User Id then you can make that the DataValueField and the UserName the DataTextField.

You can't have more than one column in the the DropDownList.

Hope everyone is having a great day!

Thanks - Jennifer
 
Would it be possible to dump the values into an arraylist and then bind the arraylist to the cboUsers control?
 
Or...

Concatenate the fields in the SQL statement...

Code:
SELECT User_Name & ' ' & User_ID AS varUsernameid FROM whatevertable

Then you can just use...
Code:
cboUsers.DataTextField = "varUsernameid"
cboUsers.DataValueField = "varUsernameid"
 
jzelhart and logicallunatic, thanks once again.
that about concatenate strings was brilliant, but i find a problem to concatenate, because user_name is string field and user_id is numeric. it gives me an error msg :/


 
try this
(user_name + ' ' + STR(user_id)
excuse me if the SQL Server code is wrong in Oracle it would be you would use CONCAT or
user_name || ' ' || TO_CHAR(user_id)
hth,
Marty
 
yes I am using sybase, i tryed cstr and it didnt work
the right one for sybase is:
string(field)

So, i this solved the problem.

Thank you people ;)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top