Display 2 Columns from a datasource in a DropDownList

  • Thread starter news-server.maine.rr.com
  • Start date
N

news-server.maine.rr.com

Hi,

Is it possible to DISPLAY 2 columns somehow in a dropdownlist?

For example:

DataField Value = bound to ProductId

DataField Display = Product Name and Product Number

Thanks for any tips.

Frank
 
B

bruce barker

other than using a fixedwidth font and spaces, no. you can build your
own dropdown in javascript.

-- bruce (sqlwork.com)
 
P

Patrick.O.Ige

Frank if inunderstand you do you want to have for example
"FirstName, Lastname" displayed in the dropdowen menu?
Patrick
 
F

Frank

For anyone else, my solution was to use an ObjectDataSource that pointed to
a custom class and method which does the database access, then returns a
collection of ListItems to be used by the DropDownList.

While pulling the fields from the SqlDataReader, I built ListItems and set
the ListItem.Text = sqlDataReader["field1"].ToString() + " " +
sqlDataReader["field2"].ToString();

Then I set the value:

myListItem.Value = "RowID";

Then add each ListItem to an ListItemCollection, and return that Collection
to the ObjectDataSource.

Works like a charm.

Frank
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top