@model MedicalVariance.Models.ViewModels.IndividualProfile
@Html.ListBox("AdministrationErrorSelected", Model.AdministrationErrorListBox, new { @class = "chzn-select" })
見栄えがよく、問題なく動作します。しかし、Webグリッドを使用したかったので、IEnumerableを作成したいと思います。
@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は冗長に見えるので、使用するのは好きではありません。