title: Nested Repeater using XMLNodeList
body: <p>I am stuck on a problem. I think I am probably close to the solution but can not seem to get there.  I have an XMLDoc that is loaded from a stored Proc, into a dataset and the xml is pulled from it, (don't think I can change any of this part).  The XML looks like this:</p>
  
  <pre><code>&lt;data&gt;
    &lt;datanode&gt;
      &lt;name&gt;11&lt;/name&gt;
      &lt;group&gt;G1&lt;/group&gt;
      &lt;value&gt;val1&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
      &lt;name&gt;12&lt;/name&gt;
      &lt;group&gt;G1&lt;/group&gt;
      &lt;value&gt;val2&lt;/value&gt;
    &lt;/datanode&gt;  
    &lt;datanode&gt;
  &lt;name&gt;21&lt;/name&gt;
  &lt;group&gt;G2&lt;/group&gt;
  &lt;value&gt;val1&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
  &lt;name&gt;22&lt;/name&gt;
  &lt;group&gt;G2&lt;/group&gt;
  &lt;value&gt;val2&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
  &lt;name&gt;23&lt;/name&gt;
  &lt;group&gt;G2&lt;/group&gt;
  &lt;value&gt;val3&lt;/value&gt;
    &lt;/datanode&gt;  
    &lt;datanode&gt;
  &lt;name&gt;31&lt;/name&gt;
  &lt;group&gt;G3&lt;/group&gt;
  &lt;value&gt;val1&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
  &lt;name&gt;32&lt;/name&gt;
  &lt;group&gt;G3&lt;/group&gt;
  &lt;value&gt;val2&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
  &lt;name&gt;33&lt;/name&gt;
  &lt;group&gt;G3&lt;/group&gt;
  &lt;value&gt;val3&lt;/value&gt;
    &lt;/datanode&gt;
    &lt;datanode&gt;
  &lt;name&gt;34&lt;/name&gt;
  &lt;group&gt;G3&lt;/group&gt;
  &lt;value&gt;val4&lt;/value&gt;
    &lt;/datanode&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>I need to use nested repeaters to display this information.  What I want is to group it by the "group" node then show each of the "datanodes" that belong to that "group" node.  So it would look something like this on the page:</p>
  
  <pre><code>G1 - has 2 nodes
  11 - Val1
  12 - Val2
  
  G2 - has 3 nodes
  21 - Val1
  22 - Val2
  23 - Val3
  
  etc
  </code></pre>
  
  <p>What I have so far:
  Default.aspx:</p>
  
  <pre><code>    &lt;asp:Repeater ID="Repeater1" runat="server"&gt;
  
      &lt;ItemTemplate&gt;
          &lt;p&gt;                
              COUNT: &lt;asp:Literal runat="server" ID="Literal3" Text='&lt;%# XPath("count(group)") %&gt;' /&gt;                
              &lt;br /&gt;Text: &lt;asp:Literal runat="server" ID="Literal4" Text='&lt;%# XPath("text()") %&gt;' /&gt;
              &lt;br /&gt;Group: &lt;asp:Literal runat="server" ID="Literal2" Text='&lt;%# XPath("group") %&gt;' /&gt;
              &lt;br /&gt;ID: &lt;asp:Literal runat="server" ID="displayname" Text='&lt;%# XPath("name") %&gt;' /&gt;
              &lt;br /&gt;VAL: &lt;asp:Literal runat="server" ID="Literal1" Text='&lt;%# XPath("value") %&gt;' /&gt;
           &lt;/p&gt;            
  
      &lt;/ItemTemplate&gt;
  
      &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Default.aspx.cs</p>
  
  <pre><code>public partial class _Default : System.Web.UI.Page
  {
      private XmlNodeList nodelist;
  
      protected void Page_Load(object sender, EventArgs e)
      {
          XmlDocument doc = new XmlDocument();
          doc.Load(@"C:\development\testforWork\WebApplication1\WebApplication1\data.xml");
  
          nodelist = doc.SelectNodes("//datanode[not(group=preceding-sibling::datanode/group)]/group");           
          //nodelist = doc.SelectNodes("//datanode[group='G2']");
  
          Repeater1.DataSource = nodelist;
          Repeater1.DataBind();
      }
  }
  </code></pre>
  
  <p>I can get them to just display each datanode one after the other, but I can not figure out how to nest the repeaters and do the grouping.  I am newish to XPath and repeaters and think I must have some gap in my knowledge and just can't connect the dots, (unless I am running down the wrong road entirely).</p>
  
  <p>Thanks</p>