【发布时间】:2019-04-16 13:27:52
【问题描述】:
我在razor mvc 中填写DropDownListFor。我正在尝试从 Navigational 属性中填充它,但它不起作用。
错误:
找不到类型或命名空间名称“模型”(您是否缺少 using 指令或程序集引用?)**
<div class="form-group">
@Html.LabelFor(model => model.InspectionReport.InspectionPhase, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-3">
@Html.DropDownListFor(model => model.InspectionReport.InitialsID, (IEnumerable<model.InspectionReport.Initials>) Model.InspectionReport.Initials,
"-Select-",
new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.InspectionReport.InspectionPhase, "", new { @class = "text-danger" })
</div>
</div>
InspectionReport.cs
namespace VAILCertificates.DAL.Entities
{
public class InspectionReport
{
//General Details
public int InspectionReportID { get; set; }
public short? InitialsID { get; set; }
public virtual Initials Initials { get; set; }
}
}
姓名首字母.cs
public class Initials
{
public short? InitialsID { get; set; }
public string Code { get; set; }
}
【问题讨论】:
-
显示你的控制器代码。
标签: c# asp.net-mvc entity-framework razor entity-framework-6