Link / join lists dynamically / programmatically

Tag: sharepoint Author: qh78560 Date: 2009-07-12

I tried making Linked lists in Sharepoint designer and it worked well - I was able to link multiple sources of lists in 1 source.

However I want to link these lists programmatically (by coding), so I could add/remove some lists based on condition (well actually I want a list with template number X added to linked source automatically).

How can I achieve that?

Best Answer

You can use the Content Query Webpart (available in MOSS) and use the ListsOverride method to specify custom list templates to be included in your search. You can do this both from your code as well as from the interface.

Here are more details, you will need to specify the list templates as


elements, according to the WSS SDK 3.0 reference.


Thank you for tip. It`s really possible to aggregate all subwebs with a single caml query. However to make queries and aggregate them programmatically, we can use SPSiteDataQuery class. Examples here: Looks like SPSiteDataQuery is even included in WSS. Goodie.