views:

1805

answers:

4

Hello All,

I have multiple SharePoint lists and want to display data from them on to a gridview control.

Please guide me.

Grace

+1  A: 

Two options that I can think of:

  1. SPSiteDataQuery
  2. Set up a search scope, metadata, and then query your Scope using Enterprise Search SQL and FullTextSqlQuery
Kit Menke
+1  A: 

With SharePoint 2007 you can use CrossListQueryCache and CrossListQueryInfo. More information here.

Alex Angas
Worth to note that these classes are available for MOSS installation only. For WSS use suggested SPSiteDataQuery.
Janis Veinbergs
That's what the question says - SharePoint 2007 not WSS 3.0.
Alex Angas
Dude, I never knew about this class. Am i correct to state that this will use some cached data as a source, i.e. like the sitemap provider?
Colin
A: 
tag
What do you miean in same sites? SiteCollection or Web? SPSiteDataQuery can be used to query ALL lists in SiteCollection (doesn't matter how SUB-Webbed it is), just define List template type.
Janis Veinbergs
There is no need to purchase a product. SharePoint provides this functionality via its API.
Alex Angas
+4  A: 

Your question inspired me to develop a web part that demonstrates:

  1. How to query SharePoint data in the many ways offered by the API, and
  2. How to bind it to a grid view.

It can be found on CodePlex here. Some of it is a little rough but it should be enough to show you the basics. It demonstrates the following query types:

  • For loop (if that counts)
  • GetListItems from Lists web service
  • SPQuery for SPList objects
  • SPSiteDataQuery for cross-site list queries
  • CrossListQueryInfo for cached cross-site list queries
  • PortalSiteMapProvider for SharePoint Server publishing sites only

There is code for using the search engine but this isn't wired up to the web part itself yet.

I hope it helps you. If you try it and have problems please use the CodePlex site to get support from me.

Alex Angas
That's cool Alex. You always do a great job. Keep up the good work!
Pradeep007
+1 for answering the question and providing a working demonstration that truly goes above and beyond!
Sean McDonough
@Grace Kim: Feel free to upvote this answer if it helps you! ;-)
Alex Angas