I’m trying to create a Create page for a slightly complex ‘view model’/view setup that I’m looking for.
Imagine I have two entities –
Person
-PersonID
-Name
-Height
-Nationality
And that Person can have multiple Addresses – here’s the Address entity:
Address
-PersonID
-AddressDescriptor
-FirstLine
-SecondLine
-City
-ZipCode
Now in my Person Create view I want the user to be able to enter the person details,
and then add as many addresses as they like.
I’m visualizing this as something like a set of text boxes for both the person and the address area. Followed by an add button for the address. When clicked this add button would add the address to a grid of added addresses. The grid would also have options for delete/edit.
Finally there would be a submit button to save the person and address records to the database.
What is my best bet for achieving something like this.
Should I be looking to use partial views for the grid / rendered by AJAX calls back to the controller? If so could someone point me to a modern example of doing this – using Razor if possible?
This runs through the basic principles of what you are trying to achieve:
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/