How to enable edition of a list inside another object in ASP.NET MVC 2
I'm pretty new to MVC2开发者_运维知识库 and need some help on how to do something. I have a Business Object which has associated a list of childs (example, A class populated with alumns). The thing is, any class can have an arbitrary number of alumns, so, how can I practically put that into a view? How will the user add new alumns or delete existing alumns to the class object, which is the one being edited?
I hope I made myself clear. Sorry no code at the moment since I still have to put up the data model and build the model objects, and then after this I'll write the Controller and the View.
Thanks!
If you're working with a collection/list of alumns then you will need to iterate over them in the view. This will enable a dynamic number of them being displayed.
Adding new ones will require calling an add action with the parent id on which it is to relate to. Similarly with delete you will need the associated id of the alumn and the parent id.
This answer from another questions with child/parent relations explains more with code.
Hope this helps
精彩评论