views:

273

answers:

1

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 happens 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 requireing 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.

A: 

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.

Echilon