Display 2 Columns from a datasource in a DropDownList

  • Thread starter Thread starter news-server.maine.rr.com
  • Start date 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
 
other than using a fixedwidth font and spaces, no. you can build your
own dropdown in javascript.

-- bruce (sqlwork.com)
 
Frank if inunderstand you do you want to have for example
"FirstName, Lastname" displayed in the dropdowen menu?
Patrick
 
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

Back
Top