C# RadGrid覆盖CreateChildControl
我正在扩展Tellick RadGrid控件,为其提供可选的CustomSearchControlC# RadGrid覆盖CreateChildControl,c#,radgrid,createchildcontrols,C#,Radgrid,Createchildcontrols,我正在扩展Tellick RadGrid控件,为其提供可选的CustomSearchControl protected override void CreateChildControls() { this.Controls.Add(CustomSearchControl); base.CreateChildControls(); this.Controls.Add(CustomSearchControl); } 似乎base.CreateChildControls()
protected override void CreateChildControls()
{
this.Controls.Add(CustomSearchControl);
base.CreateChildControls();
this.Controls.Add(CustomSearchControl);
}
似乎base.CreateChildControls()中必须有一个clear控件调用,因为第一个CustomSearchControl会消失
我试过这样做:
protected override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.AddAt(0,CustomSearchControl);
this.Controls.Add(CustomSearchControl);
}
但它会创建一个viewstate错误。。。因为这两个控件都没有添加到viewstate,而且插入操作正在破坏控件集合的层次结构。我刚刚注意到这已经打开很长时间了。我想我从来没有回来说我发现了我懊恼的根源。RadGrid中的CreateChildControls方法基本上有两种定义。我需要重写的有一个int返回签名。当我使用该方法而不是默认的void方法时,控件被成功地添加到viewstate中,并且一切正常。我只是注意到它已经打开很长时间了。我想我从来没有回来说我发现了我懊恼的根源。RadGrid中的CreateChildControls方法基本上有两种定义。我需要重写的有一个int返回签名。一旦我使用了该方法,而不是默认的void方法,控件就成功地添加到viewstate中,一切正常