in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Tobias Zimmergren's thoughts on development - MOVED!

THIS BLOG HAS MOVED!!!
NEW URL: www.zimmergren.net
Please update your RSS and bookmarks!

Any comments here will not be answered, please comment on http://www.zimmergren.net instead!
All the same posts are there

SharePoint Cross List Queries in a custom UserControl

Author: Tobias Zimmergren
Url:
http://www.sharepointblogs.com/zimmer

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:

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

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.

Comments

 

Grace said:

nice use of usercontrols with the smartparts in your articles. ajax and all that is nice.

i was just looking for how to look up things between lists, and this saved the day. i will implement it and test it out in various ways. need some additional code to it but thats not a issue.

thanks

March 10, 2008 12:24 PM
 

SharePoint Link Love: 03-10-2008 at Virtual Generations said:

Pingback from  SharePoint Link Love: 03-10-2008 at  Virtual Generations

March 10, 2008 1:05 PM
 

nicholas stevens said:

hi mr zimmergren.

Nice one. I always avoid using queries because I havnt looked at them but they seemed easy enough. ts just simple caml that needs to be used. thanks very Much!

March 11, 2008 7:02 AM
 

SharePoint, SharePoint and stuff said:

Entwicklung SharePoint Cross List Queries in a custom UserControl Adding Video to a SharePoint Site How

March 13, 2008 10:21 AM
 

Mirrored Blogs said:

Entwicklung SharePoint Cross List Queries in a custom UserControl Adding Video to a SharePoint Site How

March 13, 2008 11:26 AM
 

list of sharepoint webparts said:

Pingback from  list of sharepoint webparts

May 12, 2008 12:00 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts