title: adding nested ul list from code behind
body: <p>there. I have a ul on a webpage that I'm populating from the behind code with a database I have organized in a tree. I can get the values from the db just fine and list them altogether, but the child nodes i would like to appear in an inner list under each parent. Here's my current behind code</p>
  
  <pre><code>    protected void createMenu(TreeView navTree) {
  
          foreach(TreeNode node in navTree.Nodes){
  
          HtmlGenericControl li = new HtmlGenericControl("li");
          navMenu.Controls.Add(li);
  
          HtmlGenericControl anchor = new HtmlGenericControl("a");
          anchor.Attributes.Add("href", "");
          anchor.Attributes.Add("class", "toggle");
          anchor.Attributes.Add("onClick", "navButton");
          anchor.InnerText = node.Text;
  
          li.Controls.Add(anchor);
  
  
          foreach (TreeNode childNode in node.ChildNodes) {
  
              HtmlGenericControl child_li = new HtmlGenericControl("li");
              navMenu.Controls.Add(child_li);
  
              HtmlGenericControl childAnchor = new HtmlGenericControl("a");
              childAnchor.Attributes.Add("href", "");
              childAnchor.Attributes.Add("onClick", "childButton");
              childAnchor.InnerText = childNode.Text;
  
              child_li.Controls.Add(childAnchor);
          }
  
          }
  
      }
  </code></pre>
  
  <p>and here's the html I'm trying to recreate:</p>
  
  <pre><code>&lt;div id="sidebar"&gt;
  &lt;nav&gt;
    &lt;h2&gt;Sites&lt;/h2&gt;
    &lt;ul&gt;
      &lt;li class="toggle"&gt;&lt;a href="#"&gt;Akron&lt;/a&gt;&lt;/li&gt;
      &lt;li class="toggle"&gt;&lt;a href="#"&gt;Monterey&lt;/a&gt;&lt;/li&gt;
      &lt;li class="toggle is-open"&gt;&lt;a href="#"&gt;Sacramento&lt;/a&gt;
        &lt;ul class="subnav"&gt;
          &lt;li&gt;&lt;a class="active" href="#"&gt;&lt;span class="quantity"&gt;5&lt;/span&gt; George&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;&lt;span class="quantity"&gt;7&lt;/span&gt; John&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;&lt;span class="quantity"&gt;18&lt;/span&gt; Bob&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li class="toggle"&gt;&lt;a href="#"&gt;Stanislaus&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p></p>