DropDownList Property to display

2019-09-02 15:17发布

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条回答
祖国的老花朵
2楼-- · 2019-09-02 15:50

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

ViewBag.MedicId = new SelectList(db.Medics, "Id", "Nome");
查看更多
登录 后发表回答