internal virtual void InitRecursive(Control namingContainer)
{
    this.ResolveAdapter();
    if ((this._occasionalFields != null) && (this._occasionalFields.Controls != null))
    {
        if (this.flags[0x80])
        {
            namingContainer = this;
        }
        string errorMsg = this._occasionalFields.Controls.SetCollectionReadOnly("Parent_collections_readonly");
        int count = this._occasionalFields.Controls.Count;
        for (int i = 0; i < count; i++)
        {
            Control control = this._occasionalFields.Controls[i];
            control.UpdateNamingContainer(namingContainer);
            if (((control._id == null) && (namingContainer != null)) && !control.flags[0x40])
            {
                control.GenerateAutomaticID();
            }
            control._page = this.Page;
            control.InitRecursive(namingContainer);//在这里递归的哇
        }
        this._occasionalFields.Controls.SetCollectionReadOnly(errorMsg);
    }
    if (this._controlState < ControlState.Initialized)
    {
        this._controlState = ControlState.ChildrenInitialized;
        if (((this.Page != null) && !this.DesignMode) && (this.Page.ContainsTheme && this.EnableTheming))
        {
            this.ApplySkin(this.Page);
        }
        if (this._adapter != null)
        {
            this._adapter.OnInit(EventArgs.Empty);
        }
        else
        {
            this.OnInit(EventArgs.Empty);
        }
        this._controlState = ControlState.Initialized;
    }
    this.TrackViewState();

解决方案 »

  1.   

    上面那个太长了
    for (int i = 0; i < count; i++)
            {
                Control control = this._occasionalFields.Controls[i];
                control.UpdateNamingContainer(namingContainer);
                if (((control._id == null) && (namingContainer != null)) && !control.flags[0x40])
                {
                    control.GenerateAutomaticID();
                }
                control._page = this.Page;
                //************************************************************
                control.InitRecursive(namingContainer);//在这里递归的哇
                //************************************************************
            }