DropDownList Property to display

2019-09-02 15:41发布

问题:

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");