I do not send lists to my view through the ViewBag, instead I use my view model for this. For example, I did something like this:
I have an EditorTemplate like this:
@model IceCream.ViewModels.Toppings.ToppingsViewModel
<div>
@Html.HiddenFor(x => x.Id)
@Html.TextBoxFor(x =x> x.Name, new { @readonly="readonly"})
@Html.CheckBoxFor(x => x.IsChecked)
</div>
Views\IceCream\EditorTemplates. , html, "" - .
- :
@HtmlEditorFor(model => model.Toppings)
EditorTemplate, Toppings .
viewmodel, , , Toppings:
public IEnumerable<ToppingsViewModel> Toppings { get; set; }
, , ( , ) viewmodel . , , IsChecked TopingsViewModel, .
, , , . , , .