how can you get 2 datafields displayed in a combo box?

G

Guest

How can you get 2 datafields displayed in a combo box, and still return just
one of the fields?

I need to return a company name in order to help users visually determine
who a rep works for, but need only the repcode to pass on to another
variable.

SC
 
M

Martin Dechev

Set the DataTextField and the DataValueField properties of the DropDownList
control to the column names of the corresponding columns. If you have the
MSDN Library installed there are examples in the topics for these
properties.

Hope this helps
Martin
 
G

Guest

Martin - thanks for the response -

A follow-up question -

If I am in my select statement formatting the first of the 2 fields, for
example:

select
'(' + company + ')' as company1,
salesrepname as Salesrepname

would I need to put in the field only (company), or the result of the AS
(company1) or would it be the string formatted '('+company+')'?

Thanks,

SC
 
M

Martin Dechev

The column name will be what you specify with the AS clause, in your example
the table in the dataset should have columns with names "company1" and
"Salesrepname". The same if it is DataReader.

Hope this helps
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top