I am fairly new to ASP.NET and I want to know if its possible to route a list element to an ACTIONLINK method?
In my View I am populating an unordered list and for each item in it has a link with some values I want to pass to the next view. I do this like so:
@model MyASPApplication.Models.FooViewModel
<ul id="errors" class="collapse list-unstyled">
@for (int i = 0; i < Model.MyFooCollection.GroupBy(c => c.FooName).ToList().Count; i++)
{
<li>
@Html.ActionLink(Html.DisplayFor(model => model.MyFooCollection[i].LocationName).ToString(), "Index", "Foo", Model.MyFooCollection.ToList(), null)
</li>
}
</ul>
In my Foo Controller:
public ActionResult Index(List<FooCollection> foo) //it has a value of 0
{
...code logic here
return View();
}
When I run the application and place a breakpoint in my li element it doesn't fire when I click on its link. Am I not using the correct method? Many thanks in advance.