I am trying to display a list of objects in my asp.net view but it somehow isn't working.
VIEW
@model List<WCFasp.net.Models.ViewProject>
@{
ViewBag.Title = "ShowSelectedView";
}
@ViewBag.sl
@for (int i = 0; i < Model.Count; i++)
{
<p>@Html.DisplayFor(m => m[i].Name)</p>
}
Controller
public ActionResult Check(List<WCF.Project> selectedprojectlist)
{
List<ViewProject> selectedlist = new List<ViewProject>();
foreach (var dir in selectedprojectlist)
{
if (dir.IsChecked == true)
{
selectedlist.Add(new ViewProject(dir.Name, dir.Path, dir.Size, dir.LastChange, dir.IsChecked));
}
}
ViewBag.sl = selectedlist.Count;
return View("ShowSelectedView", selectedlist);
}
The ViewBag.sl displays Model.Count from the Controller. The Counter works and tells me there are objects in the list but it wont display them.
Does someone see an error or has an alternative idea?
controllerandviewcode separately.<p>tag rendered or not?