我有以下型号。出席和FoodPreference是枚举。
public class RsvpModel {
public RsvpPerson[] People { get; set; }
}
public class RsvpPerson {
[Required(ErrorMessage = "Required")]
[DisplayName("First Name")]
public string FirstName { get; set; }
[Required(ErrorMessage = "Required")]
[DisplayName("Last Name")]
public string LastName { get; set; }
public string Email { get; set; }
[Required(ErrorMessage = "Required")]
[DisplayName("Are you attending?")]
public Attendances? IsAttending { get; set; }
[Required(ErrorMessage = "Required")]
[DisplayName("Food Preference")]
public FoodPreference? Food { get; set; }
}
模型正在传递到我的视图
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Models.RsvpModel>" %>
然而,这显示什么,我不知道为什么。
<%= Html.DisplayFor(m => m.People[0].FirstName)%>
答案 0 :(得分:2)
我认为你必须单独添加标签:
<%= Html.LabelFor(m => m.People[0].FirstName) %>
<%= Html.DisplayFor(m => m.People[0].FirstName) %>