C# 来自ID MVC的查找名称
我目前使用下面的Razor语法从CaseStatus表中获取“Status”的名称。我将其用于视图中的DropDownListFor选项。现在,我想显示相同的数据,但用于标签。有没有一种简单的方法可以复制标签C# 来自ID MVC的查找名称,c#,model-view-controller,C#,Model View Controller,我目前使用下面的Razor语法从CaseStatus表中获取“Status”的名称。我将其用于视图中的DropDownListFor选项。现在,我想显示相同的数据,但用于标签。有没有一种简单的方法可以复制标签 @Html.DropDownListFor(m => m.CaseMaster.CaseStatusId, new SelectList(Model.CaseStatus, "Id", "Name"), "Select Status", new { @class = "form-co
@Html.DropDownListFor(m => m.CaseMaster.CaseStatusId, new SelectList(Model.CaseStatus, "Id", "Name"), "Select Status", new { @class = "form-control col-sm" })
仅此而已:
<label>@( this.Model.CaseStatus )</label>
@(this.Model.CaseStatus)
(虽然HTML中的
有一个特定的目的,用于引用其他输入元素(即for=“”
属性)或子输入元素。如果您的意思是“标签”,就像VB/WPF一样,它是屏幕上显示的一小段文本,那么您只需执行@(this.Model.CaseStatus)
直接执行。在执行此操作时,我收到System.Collections.Generic.List`1[Clope.Models.CaseStatus]。您还有其他建议吗?