2014-03-19 49 views
1

我有一個項目,我已經有veiwmodel分配的IEnumerable <int>到hiddenfor

[Required(ErrorMessage = "Enter Title")] 
    [Display(Name="Title")] 
    public string Title { get; set; } 

    [Required(ErrorMessage = "Enter Description")] 
    [Display(Name="Description")] 
    public string Description { get; set; } 

    [Required(ErrorMessage = "Select Site")] 
    [Display(Name = "Site")] 
    public string Site { get; set; } 

    [Required(ErrorMessage = "Upload File is required")] 
    [Display(Name = "Upload File")] 
    [ValidatePlanFile] 
    public HttpPostedFileBase File { get; set; } 

    public int SelectedUser { get; set; } 

    public List<Guid> Users { get; set; } 

我需要的用戶屬性分配給一個hiddenfor工作。

是否可以將IENumerable分配給視圖?

回答

1

像往常一樣,我們如何處理@Html.TextBoxFor或其他人。

@model IEnumerable<Type> 

@foreach(var item in Model) 
{ 
    @Html.HiddenFor(model => item) 
} 
相關問題