扩展控件可能不是之后preRender注册。发生在GridView控件的DataBind() [英] Extender controls may not be registered after PreRender. Occurs on GridView DataBind()

查看:120
本文介绍了扩展控件可能不是之后preRender注册。发生在GridView控件的DataBind()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的ASP.Net 4.0 C#的Web应用程序调试我得到在上述主题行中的错误。

On our ASP.Net 4.0 C# web app I get the error above in the subject line during debug.

我并不是真的做任何页面上时髦的动态控件显示某些搜索结果可能是问题的根源。

I'm not really doing anything funky with dynamic controls on the page as some search results indicated could have been the source of the problem.

该页面有2 AJAX:CalendarExtenders ,并已工作了一段时间精细

The page has 2 ajax:CalendarExtenders and has been working fine for a while.

虽然它可能有关,我可以看到真的,但这个是我目前正在对当错误出现了。

Although its probably related, I can see how really but this is what I was currently working on when the error came up.

我们有引发上自动刷新功能的活动页面上的控制。 [它是一个地图控件。

We have a control on the page that raises an event on an autorefresh feature. [Its a map control].

我的页面订阅该事件并在这样一个DataBinds ASP:GridView的。我们需要每一次,以确保电网和地图控件是同步的数据绑定在网格中。 [它是一个车辆跟踪页]

My page subscribes to that event and upon doing so DataBinds an asp:GridView. We need to bind the data in the grid every time to ensure the grid and the map control are in sync. [Its a vehicle tracking page]

上的DataBind命令出现错误。

The error occurs on the DataBind command.

我已删除的扩展程序只能拿出同样的错误。

I have removed the Extenders only to come up with the same error.

该数据绑定是直截了当的,但我敢肯定,错误别处居住。我有也无妨。

The databind is straightforward but I'm sure the error resides elsewhere. I'll include it anyway.

this.SearchGrid.DataSource = resultsWithMetrics;

        this.SearchGrid.AllowPaging = true;
        this.SearchGrid.PageIndex = this.SearchGridPager.CurrentPage;
        this.SearchGrid.AllowPaging = this.SearchGridPager.PageSize > 0;
        this.SearchGrid.PageSize = this.SearchGridPager.PageSize > 0 ? this.SearchGridPager.PageSize : this.SearchGrid.PageSize;

        this.SearchGrid.DataBind();

也许它根本不理解已经绊倒了我的页面生命周期,反正很高兴有一定的帮助。

Maybe its simply not understanding the page life cycle that has tripped me up, anyway would be glad of some help.

推荐答案

使用以下code在你的用户控件或页面控制。如果你使用任何AJAX控件它将工作。

Use the following code in your usercontrol or page control. It will work if you are using any ajax control.

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (this.DesignMode == true)
        {
            this.EnsureChildControls();
        }
        this.Page.RegisterRequiresControlState(this);
    } 

这篇关于扩展控件可能不是之后preRender注册。发生在GridView控件的DataBind()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆