Jon's Blog

.NET Development & More

DropDownList: Customized DataTextField

If you try to bind a DropDownList to a DataSouce you will find that you can only use one column as the DataTextField.  The easiest way I have found to overcome this is to manually add the items to the DropDownList like this:

foreach (var item in items)
ListItem li = new ListItem(item.FirstName + " " + item.LastName, item.ID);

You could also change your query/stored procedure to pull back what you needed displayed in a single column.  But I prefer the above method.