1

I have a model as follows:

 public abstract class Product
{
    public int ProductID { get; set; }
    public string ProductName { get; set; }
}
public class ProductA :Product
{
    public string DetailA1 { get; set; }
    public string DetailA2 { get; set; }
}
public class ProductB :Product
{
    public string DetailB1 { get; set; }
    public string DetailB2 { get; set; }
    public string DetailB3 { get; set; }
}

And i need to set a details.aspx page that will work for both of the ProductA and ProductB. So I am planning to do it with this method.

//First Modify the Product Class
  public abstract class Product
{
    public int ProductID { get; set; }
    public string ProductName { get; set; }
    public int NrofDetails {get;Set;}
    public <list>string DetailValue
         { 
             // I need a function that gets the details from subclasses and make a list
               Return List;
          }
 }

I believe that there should be an easy way to have the Detailvalue List from the sub classes. I'll be greatful if you can help on this case.

Then i will use a repeater and use Product.DetailValue as itemType and hope to have it on aspx.

Note: I am just a beginner, i read a lot about TPH but can not get the find out how to reach the fields of subclasses from the product object.

Kind Regards,

OmerGokcek
  • 11
  • 1

0 Answers0