RadGrid 覆盖 CreateChildControls
我正在扩展 Tellerick RadGrid 控件,为其提供可选的 CustomSearchControl。
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);
}
但它会创建一个视图状态错误...因为两个控件都没有添加到视图状态中,并且插入破坏了控件集合的层次结构。
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.CreateChildControls() 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚注意到这个已经开放很长时间了。我想我再也没有回来说我发现了我懊恼的根源。 RadGrid 中的 CreateChildControls 方法基本上有两个定义。我需要覆盖的那个有一个 int 返回签名。一旦我使用该方法而不是默认的 void 方法,控件就会成功添加到视图状态,并且一切正常。
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.