Hello,
Suppose I have the following model (generic example):
- Person (base class)
- Student (derived)
- Teacher (derived)
- Secretary (derived)
There are some common fields, such as first name, last name, phone nr., but several fields unique to each derived type (Student, Teacher, Secretary).
I would like to be able to display each type on a single page - say PersonDetails?
What would be the best way to approach this? My thoughts where to create a control for each type and a case-like structure in the parent page where you load the corresponding control.
While this works, I foresee problems with this route if you start adding a lot of types. Say tomorrow you add 10 types - your case will expand and you'll need to create 10 more controls. This clearly isn't a good idea nor is it efficient. Not to mention if you have several more pages, you'll need to start creating controls for those as well.
I was thinking more of working with a base class and have the control interpret the type - although this creates a huge switch case where you'll create labels and the like according to properties; doesn't seem very good either...
Does anyone know of a better way?
Thanks in advance.