DropDownList Property to display

我的梦境 提交于 2019-12-25 02:08:13

问题


I have the following classes: User and Medic, that inherits from User.

User has: Id, Name...

Medic has: Crm (numeric value)...

In a view, I want do display a DropdownList with Medic's Id for options value, and Name (inherited) for display...

But using @Html.DropDownList("MedicId") I have, for default, the Crm property being displayed.

Someone knows a way to set the display property to Name?


回答1:


Sorry, I have not observed, but in my Controller I have the way to do it

ViewBag.MedicId = new SelectList(db.Medics, "Id", "Nome");


来源:https://stackoverflow.com/questions/15713340/dropdownlist-property-to-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!