I have two tables, Author and Book, where an author can have many books. I've got an edit view set up as "System.Web.Mvc.ViewPage(of MyDatabase.Author)". The form is set up to show the Author and all his books, with the ability to edit book information:
<% Using Html.BeginForm()%>
<%=Model.author_name%> <br/>
<% For Each item In Model.Books%>
<%=Html.CheckBox("checked_out")%>
<%=item.book_name%> <br/>
<% Next%>
<input type="submit" value="Save" />
<% End Using%>
In the controller, I've got the Post function:
<ActionName("Edit"), AcceptVerbs(HttpVerbs.Post)> _
Function Save(ByVal form As Author) As ActionResult
Dim book_count = Author.Books.Count
End Function
The problem is that the Books collection isn't part of the post - book_count is zero, even though there are several books displayed.
Am I doing something wrong, or am I expecting too much in the post? How can I make this work?