Search code examples
asp.netsharepointweb-parts

Dynamically exposing WebPart connections at runtime


I'd like to try and expose some connections for a webpart at runtime, at compile time I don't know what they are, and I'm wondering if anyone can provide any suggestions on where to start. All the examples I've read seem to do so statically using [ConnectionConsumer] and [ConnectionProvider] which obviously needs to be done in code, I don't however know what I need to expose at this point in time.

My use case would be something like a grid that uses a DataTable. The DataTable is retrieved by using a SQL statement:

select * from myTable

The connections I want to expose are when this changes to

select * from myTable where columnA = myConnection1

At this point I want to expose a connection for my WebPart called 'myConnection1', if I add multiple where clauses I want multiple connections that can be linked from other WebParts.

EDIT
An example of this would be like how ReportingServices within SharePoint handles connections. It seems to use a custom WebPartManager that determines at runtime the number, names and types of connections that need exposing.


Solution

  • In the end I determined that the best way was to use the IWebPartParameters interface and expose them manually.

    http://blog.mindbusiness.de/blog/2011/09/05/implementation-of-iwebpartparameters-web-part/