子项的服务器控件集合的递归函数

|| 我可以控制带有子项目的列表。我需要有一个收集子项的递归函数。 例如,如何收集和迭代包含子项的此收集? ArrayList MenuItems是要使用的适当类型吗?
<myControl:Menu id=\"MyControl\" runat=\"server\">
    <mycontrol:MenuItem Text=\"Hellow World\">
        <mycontrol:MenuItem Text=\"Hellow World\">
             <mycontrol:MenuItem Text=\"Hellow World\" />         
        </myControl:menuItem>
    </myControl:menuItem>
</myControl:Menu>
这是控件:
  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);
        }
    }
}
    
已邀请:

要回复问题请先登录注册