Hi,
I have problem concerning the connecting provider and consumer after page events are raised. Let's start with little bit background information and head step-by-step to actual problem.
I'm developing enterprise level solution using the web part architecture. Portal framework provides us highly flexible platform to customize the layouts (master pages, web parts etc.) and functionalities based on roles, licenses etc. Dynamic loading of the WebParts is adaptation of the Mike Harder's PDC05 samples (loading web parts based on settings in database with customized WebPartManager in OnInit stage - Excellent example by the way).
The problem which I ran into is the event sequence and the connection creation between web parts. We have separate business logic layer, which unfortunately can not be used (at least now) with the objectDataSource, so the approach is that the provider web part provides the necessary information for the consumer and the consumer renders the necessary functionality based on that.
So. I have one list web part (with composite control, rendering in gridview) and one details web part (with composite control, rendering in detailsview).
- List web part provides the collection of entities and the selected index for the details web part
- Details web part renders the content to details view
If we change the details view mode to edit by f.ex. using the standard edit command field, the edit event is raised before the connection is created. There for we get error, since the necessary data required for the functionality is not available. I was planning to bind the collection to consumer side web part in the CreateChildConrols method, so that the necessary information would exist for the even handling.
Any thoughts? So the question is:
Is there a way to make sure that the connection creation happens before the events are raised?
This is not an issue, if we use user controls for rendering the data and handle the events on normal page, as we can see from the Basic Instinct Article: http://msdn.microsoft.com/msdnmag/issues/06/02/BasicInstincts/. In our case however the web parts are in seperate assembly and inherited from the webpart class.
Basically the web part connections are created (checked using the Reflector - Magnificent tool) after the Page LoadComplete event. WebPartManagers creates the dynamic connections from the StaticConnection collection (and from few other places). Can I by pass the problem using ConnectWebParts method of the WebPartManager (I'm testing this nevertheless today) for connecting the necessary web parts? Currently I'm connecting them using the StaticConnections collection.
Thanks for any comments.
- Vsku
Vesa Juvonen