title: Recursive Function for Server Control Collection of subitems
body: <p>I have control that has a list of items with subitems. I need to have a recursive function that collects the sub items.<br>
  e.g How do I collect and iterate this collection that has sub items?<br>
  is an ArrayList MenuItems the appropriate Type to use?</p>
  
  <pre><code>&lt;myControl:Menu id="MyControl" runat="server"&gt;
      &lt;mycontrol:MenuItem Text="Hellow World"&gt;
          &lt;mycontrol:MenuItem Text="Hellow World"&gt;
               &lt;mycontrol:MenuItem Text="Hellow World" /&gt;         
          &lt;/myControl:menuItem&gt;
      &lt;/myControl:menuItem&gt;
  &lt;/myControl:Menu&gt;
  </code></pre>
  
  <p>Here is the control:</p>
  
  <pre><code>  public class QuickControl: WebControl
    {
      private ArrayList MenuItems;
  
      [
      Category("Behavior"),
      Description("The contacts collection"),
      DesignerSerializationVisibility(
          DesignerSerializationVisibility.Content),
      Editor(typeof(MenuCollectionEditor), typeof(UITypeEditor)),
      PersistenceMode(PersistenceMode.InnerDefaultProperty)
      ]
      public ArrayList MenuItems
      {
          get
          {
              if (MenuList == null)
              {
                  MenuList = new ArrayList();
              }
              return MenuList;
          }
      }
  
  
      // The contacts are rendered in an HTML table.
      protected override void RenderContents(
          HtmlTextWriter writer)
      {
          Table t = CreateContactsTable();
          if (t != null)
          {
              t.RenderControl(writer);
          }
      }
  }
  </code></pre>