SPGridView
(1)
ASP.NET
(1)
CreateChildrernControls
(1)
ObjectDataSource
(1)
WebPartManager
(1)
ConnectionProvider
(1)
ConnectionConsumer
(1)
ConnexionConsumer
(1)

Passing parameters from one webpart to another

Asked By Thomas
19-Aug-07 10:32 AM
Hello,

I'm stuck with following problem. I have two webparts on one page. I would
like to pass parameters from one webpart to another. I used for that the
ConnexionProvider and ConnexionConsumer pattern. All works fine except one
thing.
In the second WebPart (ConnexionConsumer) the data is displayed in a
SPGridView which is bound to ObjectDataSource with SelectMethod set to the
method that retrives data from the data base. The problem is that I noticed
that SelectMethod fires only once, on the firts page render. When I select
values in the first webpart and do the postback (submit) the second webpart
receives values in connexionconsumer method but the select method didn't
fire so the old data is displayed without taking into acount the new
parameters received from the first webpart.
SpGridView is bound to ObjectDataSource in CreateChildrernControls Method. I
would like that ObjectDataSource fires select method on each pagepostback
and take into account values received from firts webpart by
connexionconsumer method. What I'm doing wrong ???

Thanks,

Thomas

Hi Thomas,My suggestion will be to first trace where the events are happening.

Asked By humbleapprentic
20-Aug-07 06:26 AM
Hi Thomas,

My suggestion will be to first trace where the events are happening. Take
your webpart and place it in an ASP.NET portal framework page, set your break
points and test it. I found that if you want to connect web parts using the
portal framework you have to do it programmaticaly (supposedly you can do it
at run time but I still learning the portal framework). To connect them there
are a few steps to follow:

* Provide a definition for "ConnectionConsumer" and "ConnectionProvider"
* OnInit should create a handler for Page_Load (so Page.Load += new
EventHandler(Page_Load);)
* On page load create a WebPartManager.ConnectionsActivating += new
EventHandler(WebPartManager_ConnectionsActivating);

Here is a few links that could help you:

http://www.carlosag.net/Articles/WebParts/moreRealSample.aspx
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/webparts/connections.aspx
http://msdn.microsoft.com/msdnmag/issues/06/02/BasicInstincts/.

You don't have to use IField if you don't want to, as long as they share a
common interface is all good. Let me know if you need more, I am working on a
similar project (and it is painful so I want to safe others the pain).

Cheers,

humble.apprentice

Passing parameters from one webpart to another

Asked By Thomas
20-Aug-07 05:00 PM
Thanks a lot for your help :) It was very usefull

Cheers,

Thomas
Post Question To EggHeadCafe