views:

4829

answers:

1

Hi All,

I have a ListView inside of an Update Panel and wanted to change the Select Query from the code behind fired by a button click event and then reload the ListView inside of the Update Panel. Does anyone know how to cause the Update Panel to refresh from the code behind?

Thanks, Sean

+4  A: 

Just do:

YourUpdatePanelId.Update();

From MSDN:

If the page is enabled for partial-page rendering, when you invoke the Update method, the UpdatePanel control's content is updated in the browser. Call the Update method if you have server code that must execute to determine whether an UpdatePanel control should be updated. If you plan to use the Update method, set the UpdateMode property to Conditional. If you want the decision to update the panel to be determined in server logic, make sure that the ChildrenAsTriggers property is false and that no explicit triggers are defined for the panel.

In a typical page development scenario, if you define triggers or if the ChildrenAsTriggers property is true for the UpdatePanel control, the Update method is automatically called during the page life cycle.

If the ContentTemplate property is not defined for the UpdatePanel control, no updates of the panel will occur.

FlySwat
Thanks! This saved me a lot of problems :)
Hugo Estrada