Author: esparagus | Posted on: 2/10/2010 6:44:52 AM | Views : 310

Plesase examine the following code snippet. It was shortened but has all important bits.
I have a 'Client' class and two classes that inherit from this class: 'NaturalPerson' and 'LegalPerson'.
In my data access code i generate a generic list of Clients (List<Client>). This list includes some LegalPersons and some NaturalPersons.
When i try to bind this list to a datagrid i get the 'Object does not match target type' error.

public class Client
{

public virtual String Name
{
get { return ""; }
set { }
}
}


public class NaturalPerson: Client
{

private String firstName;
public String FirstName
{
get { return this.firstName; }
set { this.firstName = value.Trim(); }
}

private String lastName;
public Stri ...

Go to the complete details ...