SharePoint Cross List Queries in a custom UserControl 

Author: Tobias Zimmergren
Url:
http://www.zimmergren.net

I got the question last week weather it's possible to get items from all lists of <your chosen type here> gathered and displayed on one page.
This is - like most things - possible in SharePoint without any greater efforts. With something called Queries we can use the object model to query SharePoint and get a result quite painlessly.

To demonstrate a very simple example, I've created a very small usercontrol (for use with Jan Tielen's SmartPart) that looks like this:

 crossqueries1

This code will combine all the items in all of the TaskLists on the current SiteCollection and display them in a simple GridView as seen above in the screenshot.

Code for the Cross List Query UserControl

 crossqueries2

 crossqueries3

Simple enough, huh?
Of course you can create webparts, usercontrols, application pages, or any other type of application to interact with the object model in this way. I chose to do it using a UserControl for the ease of deployment, testing, development and demonstration.

For your conveniance I've uploaded the UserControl (.zip) here so you can download it.

 
Posted on 9-Mar-08 by Zimmergren
1 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
Tags: Custom Search, MOSS 2007, Queries, Search, SharePoint, WSS 3.0
 

Links to this post (Trackbacks/Pingbacks)

Comments

Name:
URL:
Email:
Comments:


MCTS WSS 3.0 (Developer and Administration/Configuration) MCTS MOSS 2007 (Developer and Administration/Configuration) MCP