I want to add additional data to the view. I want to put it into ViewBag
and later iterate it by simple for each like that:
@foreach (var message in ViewBag.Messages) {
<p>
@using (Html.BeginForm()) {
@Html.EditorFor(x => message.contents)
<input type="submit" />
}
</p>
}
In controller should I state:
ViewBag.Messages = db.Messages.ToList(); //passing List
or just:
ViewBag.Messages = db.Messages; //passing DbSet
Question: Which will work with my loop.