2016-01-13 75 views
-1
[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個屬性名稱,但其他的顯示名稱不轉換

+0

請提供更多的信息。你如何使用它?你能指望什麼? –

+0

他們是'int'.You不能顯示他們 – Raviteja

+0

期望前3,其他人是關係鍵我猜 – Zergling

回答

0
@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" }) 
-1

可能架式.cshtml包含任何領域的文字字符串從相關表。