开发者

ASP.NET GridView and UpdatePanel

I have a GridView, inside a UserControl, inside an UpdatePanel on a page.

There's a Button in the GridView which needs to fire a PostBack. What happe开发者_运维百科ns is: User clicks Button -> RowCommand Fires -> Custom event is raised on UserControl -> Page detects this and changes the active view index for a MultiView and also the page title and some other controls outside the UpdatePanel.

The problem is, the page posts back asyncchronously, the page title changes, but the actions requiring a full PostBack don't happen because a full PostBack doesn't occur.

To register the button as a PostBack trigger I'm using:

ImageButton btnResults = e.Row.FindControl("btnResults") as ImageButton;
ScriptManager scrCurrent = ScriptManager.GetCurrent(this.Page);
if (btnResults != null && scrCurrent != null) {
    scrCurrent.RegisterPostBackControl(btnResults);
}

I know this is a bit of a complicated problem, but I'd really appreciate any help.


The eventual solution was to use the above code as is, but in the RowCreated event instead of the RowDataBound. Evidently one of the quirks of ASP.NET, sometimes event order is surprising and seemingly unpredictable. For the same reason, I've always found it best to register JavaScript as late as possible, so I usually use the SaveStateComplete event.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜