Freigeben über


Refreshing one user control webpart from another user control webpart through code.

Enterprise portal supports connecting webparts and passing context between them. In some cases, you may want to refresh the consumer webpart from the provider webpart even if the context is not changing.

 

For example

1) UserControl1 is a grid of header rows (ex. Rental header) and serves as provider. Besides the grid, there is an action button on the user control.
2) UserControl2 is a grid of line rows (ex. Rental lines) and is the consumer

In User control 1 when the action button is clicked, you are calling X++ method which inserts record in the rental lines table through business logic and you want to refresh the UserControl2 , even though the context has not changed.

 

In this case , in the button click event you can fire the currentcontextchanged by yourself, so that the consumer webpart will reload itself.

Microsoft.Dynamics.Framework.Portal.UI.IAxContext contextInterface = Microsoft.Dynamics.Framework.Portal.UI.AxContextHelper.FindIAxContext(this);

contextInterface.FireCurrentContextChanged();

 

For this to work make sure

(1) UserControl1 atleast has one AXDataSourceControl with the Role set to Provider Consumer or Provider

(2) WebPart1’s (hosting UserControl1 ) Role is set to Provider in SharePoint Web Part Page

(3) WebPart2’s 9 hosting UserControl2) Role is set to Consumer in SharePoint Web Part Page

(4) WebPart1 and WebPart2 are connected in SharePoint Web Part Page to pass the AXContextList