Show different sub-sets of a view model's properties in an edit view
        Posted  
        
            by Martin R-L
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Martin R-L
        
        
        
        Published on 2010-04-29T18:38:58Z
        Indexed on 
            2010/04/29
            22:17 UTC
        
        
        Read the original article
        Hit count: 354
        
c#
|asp.net-mvc
In the context of C# 4, ASP.NET MVC 2, and NHibernate; I've got the following scenario:
Let's assume an entity Product that have an association to ProductType.
In a product edit view; how do I implement that only a sub-set of the product's properties are shown based on the ProductType association in an elegant and DRY way? I.e., different properties shall be shown for different values of a property of the ProductType.
Use a product view model builder, and from different view models automagically generate the view with my own Html.EditorForModel() (including drop-downs and other stuff not out-of-the-box)?
Attribute the properties of one view model and use the Html.EditorForModel() way aforementioned?
Use one model, but implement different web controls (view strategies) (can it be done DRY?)?
Something else entirely?
© Stack Overflow or respective owner