title: Hierarchical data using Custom objects (telerik RadGridView)
body: <p>Suppose i have</p>
  
  <pre><code>class Person
  {
      public int Id {get;set;}
      public string Name {get;set;}
      public List&lt;Person&gt; All {get;set;}
  
      public Person()
      {
      }
  
      public List&lt;Person&gt; GetAll()
      {
          //fills the list with person and returns
      }
  }
  </code></pre>
  
  <p>and that i have:</p>
  
  <pre><code>class Address 
  {
      public int PersonId {get;set;}
      public string theAddress {get;set;}
      public List&lt;Address&gt; All {get;set;}
  
      //constructor, etc
  
      public List&lt;Address&gt; GetAll()
      {
          //fills the address list and returns
      }
  }
  </code></pre>
  
  <p>What im trying to do is exactly the following:</p>
  
  <pre><code>//filling the maintemplate with data
  radGridView1.DataMember = "Person";
  radGridView1.DataSource = new Person().GetAll();     
  
  //address template, the child one
  GridViewTemplate template = new GridViewTemplate();
  template.DataSource = new Address().GetAll();
  template.DataMember = "Address";
  radGridView1.MasterTemplate.Templates.Add(template);
  
  //now the relation between those 2 classes
  
  GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
  relation.ChildTemplate = template;
  relation.RelationName = "PersonAddress"; //just a name
  relation.ParentColumnNames.Add("Id"); //field to be "joined" to create the relation
  relation.ChildColumnNames.Add("PersonId"); //same as above
  radGridView1.Relations.Add(relation);
  </code></pre>
  
  <p>and what i get is exactly a gridview with a "+" sign by the side of each Person
  The problem is, the "child" grid is EMPTY, and if i try to add data (its, by default, allowed with an empty constructor in the class) i throw an NullArgumentException</p>
  
  <p>Any ideas? im almost giving up. My problem is: i use custom objects on all projects, its not like "yo use datasets, its ready to use etc", i know that, but i would like to know if there's a way to use CUSTOM OBJECTS, or if im done and should try datasets...</p>
  
  <p>Thanks guys</p>