DropDownList要显示的属性 [英] DropDownList Property to display

查看:210
本文介绍了DropDownList要显示的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类:
用户 Medic ,继承自用户

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

用户有:
ID 名称 ...

有:
Crm (数值)...

Medic has: Crm (numeric value)...

一个视图,我想要显示一个DropdownList与Medic的 Id 的选项值,和名称(继承)显示。

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

但是,使用 @ Html.DropDownList(MedicId)我默认使用 Crm 属性正在显示。

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

有人知道一种将display属性设置为 Name

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

推荐答案

对不起,我没有观察到,但在我的控制器我有办法做到

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

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

这篇关于DropDownList要显示的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆