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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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

Back
Top