Modeling IList in Final ASP.Net MVC

There are many examples of how to use the built-in model binding to automatically retrieve a list of items. But they all refer to the beta versions of ASP.net MVC. It also mentions that there have been changes to this model binding, but so far I have not been able to find a good source of how it now works in the final version. And I am far from being able to interpret the original code :-)

So it would be great if someone could explain to me how I would need to prepare a list of values ​​in a view in order to get it back into the IList of certain objects.

appreciate your help

Maik

+1


a source to share


1 answer


View:

<% using(Html.BeginForm("Retrieve", "Home")) %> { %>
<% var counter = 0; %>
    <% foreach (var app in newApps) { %>
    <tr>
        <td><%=Html.CheckBox(String.Format("myAppList[{0}].Id", counter), app.ApplicationId) %></td>
        <!-- ... -->
        <td><%=Html.Input(String.Format("myAppList[{0}].SomeProperty1", counter), app.SomeProperty1) %></td>
        <td><%=Html.Input(String.Format("myAppList[{0}].SomePropertyN", counter), app.SomePropertyN) %></td>
        <% counter = counter + 1; %>
    </tr>
    <% } %>
    <input type"submit" />
<% } %>

      



Controller:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Retrieve(IList<MyAppObject> myAppList)

      

+3


a source







All Articles