Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RadGrid覆盖CreateChildControl_C#_Radgrid_Createchildcontrols - Fatal编程技术网

C# RadGrid覆盖CreateChildControl

C# 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()

我正在扩展Tellick RadGrid控件,为其提供可选的CustomSearchControl

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中,一切正常