title: What is the Best way to databind an ASP.NET TreeView for table with many to many parent child relationships
body: <p>I've got a table which has the usual ParentID, ChildID as it's first two columns in a self-referencing tree data structure.</p>
  
  <p>My issue is that when I pull this out and use the following code:</p>
  
  <pre><code>DataSet set = DA.GetNewCategories();
          set.Relations.Add(
              new DataRelation("parentChildCategories", set.Tables[0].Columns["CategoryParentID"], set.Tables[0].Columns["CategoryID"])
              );
          StringBuilder buildXml = new StringBuilder();
          StringWriter writer = new StringWriter(buildXml);
          set.WriteXml(writer);
          TreeView2.DataSource = new HierarchicalDataSet(set, "CategoryID", "CategoryParentID");
          TreeView2.DataBind();
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>These columns don't currently have unique values
  </code></pre>
  
  <p>I believe this is because my data has children with multiple parent nodes.  This is fine for my application - I don't mind if one row of data is rendered in multiple nodes of my TreeView.</p>
  
  <p>Could someone shed light on this please?  It doesn't seem unreasonable to have a DataSet render XML which has nodes appearing in multiple places, but I can't figure out how to do it.</p>
  
  <p>Thanks,</p>
  
  <p>Matt.</p>