我正在返回一些存储的联系人以供DropDownList查看,但我无法在我的SelectList中包含多个dataTextFields。
目前我有:
@Html.DropDownListFor(model => model.Account.AccountContacts,
new SelectList(ViewBag.DDContacts, "Contact.ContactID", "Contact.FirstName"),
new { @class = "select", style = "width: 100px;" })
我想要:
@Html.DropDownListFor(model => model.Account.AccountContacts,
new SelectList(ViewBag.DDContacts, "Contact.ContactID", "Contact.FullName"),
new { @class = "select", style = "width: 100px;" })
将FirstName和LastName属性结合起来的方法。
更新:我知道可以扩展联系人属性,但我想知道是否有一种更简单的方法在View或Controller中实现。我尝试了这里提供的两种解决方案,但无法成功。如何在SelectList文本描述中组合两个字段?