@model MedicalVariance.Models.ViewModels.IndividualProfile
@Html.ListBox("AdministrationErrorSelected", Model.AdministrationErrorListBox, new { @class = "chzn-select" })
它看起来很棒,但是效果很好!但我想做一个 IEnumerable 因为我想使用 webgrid。
@model IEnumerable<MedicalVariance.Models.ViewModels.IndividualProfile>
@Html.ListBox("AdministrationErrorSelected", foreach(var model in Model)model.AdministrationErrorListBox, new { @class = "chzn-select" })
@{
var grid = new WebGrid(source:Model, canPage: true, rowsPerPage: 5,fieldNamePrefix:"details");
.... wouldnt work if the Model was not IEnumerable...
}
还有更好的方法吗?我不喜欢使用 foreach 因为它看起来很冗长。