SharePoint Cross List Queries in a custom UserControl

Tobias Zimmergren
Tobias Zimmergren

Author: Tobias Zimmergren

I got the question last week weather it’s possible to get items from all lists of 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.


Tobias Zimmergren Twitter

Hi, I'm Tobias. I plan, architect and develop software and distributed cloud services. Nice to meet you!

Reactions and mentions

Hi, I'm Tobias 👋

Tobias Zimmergren profile picture

Find out more about me.

Recent comments

Recommended books!

Prepare for the AZ-500 exam!
Exam Ref AZ-500 Microsoft Azure Security Technologies
Azure Security Handbook!
Azure Security Handbook: A Comprehensive Guide for Defending Your Enterprise Environment
Prepare for the SC-900 exam!
Exam Ref SC-900 Microsoft Security, Compliance, and Identity Fundamentals