In a .cshtml razor view,
This works:
@Html.DropDownListFor(
m => m.PersonId, //bound value
new SelectList(Model.Persons, "PersonId", "FirstName" , 0), //list
" -- Select A Person -- " //default
)
However, Model.Persons, in addition to containing Model.Persons.PersonId and Model.Persons.FirstName, also contains Model.Persons.LastName.
How can I have the last name also show up in the select list as another column?
Add a property “Full Name” that is a ready only property that returns both of those properties. You can then use that in place of “FirstName”