Asp.net mvc显示名称不起作用
问题描述:
[Required]
[StringLength(50)]
[Display(Name="Ad")]
public string Name { get; set; }
[Column(TypeName = "date")]
[Display(Name = "Tarih")]
public DateTime Date { get; set; }
[Display(Name = "Açıklama")]
public string Description { get; set; }
//[Display(Name = "Yetkili Kişi")]
[DisplayName("Yetkili Kişi")]
public int? AuthPersonId { get; set; }
[Display(Name = "Durumu")]
public short Status { get; set; }
[Display(Name = "Müşteri")]
public int? ClientId { get; set; }
[Display(Name = "Aracı")]
public int? DealerId { get; set; }
这部分是视图------------------------------- ----------------------------Asp.net mvc显示名称不起作用
<div class="form-group">
@Html.LabelFor(model => model.Job.Name, htmlAttributes: new { @class = "text-left control-label col-md-3" })
<div class="col-md-9">
@Html.EditorFor(model => model.Job.Name, new { htmlAttributes = new { @class = "form-control col-md-4" } })
@Html.ValidationMessageFor(model => model.Job.Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.Date, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.EditorFor(model => model.Job.Date, new { htmlAttributes = new { @class = "IsSurec form-control" } })
@Html.ValidationMessageFor(model => model.Job.Date, "", new { @class = "text-danger" })
</div>
</div>
<script type="text/javascript">
$(function() {
$('.IsSurec').datetimepicker({
locale: "tr",
format: "DD.MM.YYYY"
});
});
</script>
<div class="form-group">
@Html.LabelFor(model => model.Job.Description, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.EditorFor(model => model.Job.Description, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Job.Description, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.AuthPersonId, "AuthPersonId", htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("AuthPersonId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Job.AuthPersonId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.Status, "Status", htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("Status", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Job.Status, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.ClientId, "ClientId", htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("ClientId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Job.ClientId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Job.DealerId, "DealerId", htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("DealerId", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Job.DealerId, "", new { @class = "text-danger" })
</div>
</div>
输出:
广告 Tarih Açıklama AuthPersonId 状态 的ClientID DealerId
这是转换前3个属性名称,但其他的显示名称不转换
答
@Html.LabelFor(model => model.Job.AuthPersonId, "AuthPersonId", htmlAttributes: new { @class = "control-label col-md-3" })
解决方案
@Html.LabelFor(model => model.Job.AuthPersonId, htmlAttributes: new { @class = "control-label col-md-3" })
答
可能架式.cshtml包含任何领域的文字字符串从相关表。
请提供更多的信息。你如何使用它?你能指望什么? –
他们是'int'.You不能显示他们 – Raviteja
期望前3,其他人是关系键我猜 – Zergling