开发者

RadGrid override CreateChildControls

开发者 https://www.devze.com 2023-01-15 22:15 出处:网络
I\'m extending the tellerick RadGrid control to give it an optional CustomSearchControl. protected override void CreateChildControls()

I'm extending the tellerick RadGrid control to give it an optional CustomSearchControl.

protected override void CreateChildControls()
{

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

It seems that base.CreateChildCont开发者_如何学Pythonrols() must have a clear controls call in it because the first CustomSearchControl disappears.

I tried this instead:

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

But it creates a viewstate error... as neither control is being added to the viewstate and the insert is breaking the hierarchy of the controls collection.


I just noticed this has been left open for a long time. I guess I never came back to say that I discovered the source of my chagrin. Basically there are two definitions for the CreateChildControls method in the RadGrid. The one I needed to override has an int return signature. Once I used that method as opposed to the default void method the controls were added successfully to the viewstate and all was right with the world.

0

精彩评论

暂无评论...
验证码 换一张
取 消