A design pattern for data binding an object (with subclasses) to asp.net user control
Posted
by
Rohith Nair
on Programmers
See other posts from Programmers
or by Rohith Nair
Published on 2013-02-12T19:27:57Z
Indexed on
2013/06/30
22:27 UTC
Read the original article
Hit count: 454
I have an abstract class called Address and I am deriving three classes ; HomeAddress, Work Address, NextOfKin address.
My idea is to bind this to a usercontrol and based on the type of Address it should bind properly to the ASP.NET user control.
My idea is the user control doesn't know which address it is going to present and based on the type it will parse accordingly.
How can I design such a setup, based on the fact that, the user control can take any type of address and bind accordingly.
I know of one method like :- Declare class objects for all the three types (Home,Work,NextOfKin). Declare an enum to hold these types and based on the type of this enum passed to user control, instantiate the appropriate object based on setter injection.
As a part of my generic design, I just created a class structure like this :-
I know I am missing a lot of pieces in design. Can anybody give me an idea of how to approach this in proper way.
© Programmers or respective owner