listreportviewerinherited

ReportViewer Table with list of inherited objects


I need to show a table with a list of inherited objects. For example:

public abstract class Animal
{
    public string Name { get; set; }
    public abstract string Detail { get; }
}

public class Dog : Animal
{
    public override Detail { get { return "A dog"; } }
}

public class Cat : Animal
{
    public override Detail { get { return "A cat"; } }
}

It seems that the datasource takes de first object class type and the other objects shows with #ERROR How I can fix it?


Solution

  • You need to map your properties using the expressions area. If you want to show a column with the cats details, add this to the expression for that field.

    =Fields!Cat.Value.Detail