我正在扩展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);
}但它会创建一个视图状态错误...因为这两个控件都没有添加到视图状态中,而插入操作破坏了controls集合的层次结构。
发布于 2010-11-18 23:18:58
我只是注意到这个已经开了很长时间了。我想我再也不会回来说我发现了我恼怒的根源。基本上,RadGrid中的CreateChildControls方法有两个定义。我需要覆盖的那个函数有一个int返回签名。一旦我使用了该方法,而不是默认的void方法,控件就成功地添加到了视图状态中,并且一切正常。
https://stackoverflow.com/questions/3670508
复制相似问题