【问题标题】:RadGrid override CreateChildControlsRadGrid 覆盖 CreateChildControls
【发布时间】:2011-04-09 21:19:59
【问题描述】:

我正在扩展 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);
}

但是它会创建一个视图状态错误...因为两个控件都没有添加到视图状态中,并且插入破坏了控件集合的层次结构。

【问题讨论】:

    标签: c# radgrid createchildcontrols


    【解决方案1】:

    我刚刚注意到它已经打开了很长时间。我想我再也没有回来说我发现了我懊恼的根源。基本上,RadGrid 中的 CreateChildControls 方法有两个定义。我需要覆盖的那个有一个 int 返回签名。一旦我使用该方法而不是默认的 void 方法,控件就会成功添加到视图状态,并且一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-02
      • 2011-06-11
      • 2012-01-28
      • 2012-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多