List Of All Lists In A Web Using ListOfLists DataSourceMode
I wrote earlier about using a SOAP service to get an inventory of lists within a certain site. This post uses a different approach and can also be filtered for a particular type of list. So, if you need to view all task lists or calendars or document libraries or surveys or even external lists based on the __spBaseTemplate property.![]()
The approach is fairly simple. Create a web part page in the relevant site and insert an empty data view (insert – data view – empty data view). You will get a link to select a datasource and you can select any list (in this example, the Links list was selected – random selection). You have a few fields selected in the data source details pane to the right, so you just select the “Insert selected fields as …” and choose Multiple Item View from the drop down (this is in the data source details pane near the top, select view/data source from the ribbon if the datasource is not visible). You should see some rows if the selected list is not empty.
Now, switch to code view (bottom left of the status bar) and locate the <SharePoint:SPDataSource runat=”server” DataSourceMode=”List” fragment of the code and change List to ListOfLists and switch back to design view.
You may notice something strange: a grid with several rows and no data inside. That’s ok. We’ll fix soon. While the dataform web part is selected, go to Add/Remove columns from the ribbon (data view tools – options tab). Remove the select fields (right side) and select a few of those starting with 2 underscores (__). Enlarge the image of the example to get a few to start with (I did not rename them for illustration, you should). In the Paging option (next to add/remove columns), select Display all items. That should give you a list of all lists (libraries included) within the site.
if you want just a specific type of list, click Filter (ribbon options) and then from the filter dialog, check add XSLT filtering and click Edit to add your filter. For example, use [@__spBaseTemplate='ExternalList'] to get only external lists.
You can adjust to dataform view, link lists or conditional format as you need, including the title of the web part which is named after your selected list by default. Notice that this works within one site (by default, the site you created the page in).



