It's a multi-model view, and I'm achieving this through an IList<Book>
. Each Book has a Title and an Author
So for example if I wanted to make 3 Books:
<%= Html.TextBoxFor(m => m[0].Title) %>
<%= Html.TextBoxFor(m => m[0].Author) %>
<%= Html.TextBoxFor(m => m[1].Title) %>
<%= Html.TextBoxFor(m => m[1].Author) %>
<%= Html.TextBoxFor(m => m[2].Title) %>
<%= Html.TextBoxFor(m => m[2].Author) %>
and so forth.
However, I want to be able to generate such a form for any number of Books. I've done this before in Ruby on Rails through JavaScript and rendering partials, but I don't think I can render a partial in this case because the form changes (the index of the book has to increment for it to work)
EDIT: I'm looking for a way to do this in the Create view in particular. So in this case I don't have a list of books, but I'm building it.
A user should be able to click on a link that says "Add another item" and a form for another book should be appended to the bottom.
Any ideas? Some sample code would be extremely helpful (I'm very new to ASP.NET)!