Reputation: 3236
@model MedicalVariance.Models.ViewModels.IndividualProfile
@Html.ListBox("AdministrationErrorSelected", Model.AdministrationErrorListBox, new { @class = "chzn-select" })
It look great and works just fine however! But I want to make an IEnumerable because I wanted to use a 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...
}
Any better ways? I dont like using foreach because it seems verbose.
Upvotes: 1
Views: 1150
Reputation: 12366
You can use it like this:
@Html.ListBox("AdministrationErrorSelected", new SelectList(Model.Select(s => s.AdministrationErrorListBox)), new { @class = "chzn-select" });
Upvotes: 1