2010-09-08 21 views
1

我將tellerick RadGrid控件擴展爲可選的CustomSearchControl。RadGrid覆蓋CreateChildControls

protected override void CreateChildControls() 
{ 

    this.Controls.Add(CustomSearchControl); 
    base.CreateChildControls(); 
    this.Controls.Add(CustomSearchControl); 
} 

似乎base.CreateChildControls()必須有明確的控制調用它,因爲第一CustomSearchControl消失。

我嘗試這樣做,而不是:

protected override void CreateChildControls() 
{ 
    base.CreateChildControls(); 
    this.Controls.AddAt(0,CustomSearchControl); 
    this.Controls.Add(CustomSearchControl); 
} 

但它創建一個視圖狀態錯誤...既不控制被添加到視圖狀態和刀片更是打破了控件集合的層次結構。

回答

1

我剛纔注意到這個已經打開很久了。我想我從來沒有回來說我發現了我的懊惱來源。基本上RadGrid中有兩個CreateChildControls方法的定義。我需要重寫的一個int返回簽名。一旦我使用該方法而不是默認的void方法,控件就成功添加到視圖狀態,並且全部都與世界一致。