views:

166

answers:

1

so i have a "Parents" controller with list and edit view for it (to view add/edit/delete parents)

and a "Children" controller same thing (view list add/edit/delete children)

and now i need to refactor; to put the children view inside the parent view, so that when you edit a parent you can see the list of his children and edit/delte/add some children

what's the best way to do that in asp.net mvc, is there any patterns for that or something


i tried to use RenderAction() and it works fine it shows the list of users, but the problem is that you click the edit button for a users -> edit some data -> click save and you return not to the parent edit view with the list of users but just to the list of users view

+1  A: 

You should create a Partial View that is strongly typed to your Children's Class.

Then include that on your Parent's page using HTML.RenderPartial().

This can be updated using AJAX, if needed.

skalburgi
Agree 100%. You can have a partial view for your "Children Summary" which displays your list of children, which can be re-used wherever you need to show a list of children Maybe there is some mileage in having a "Person Summary", which can be used to list "People" not just "Children".
Sohnee
i tried to use RenderAction()and it works fine it shows the list of users, but the problem is that you click the edit button for a users -> edit some data -> click save and you return not to the parent edit view with the list of users but just to the list of users view
Omu
In the Edit method of your controller, instead of returning the User View do a RedirectToAction("Parent", "Parents", new { id = parentID})
skalburgi
yes, probably that's how i should have done it, but i did it already
Omu