How to query data in SharePoint from multiple lists

跟風遠走 提交于 2019-12-21 20:38:07

问题


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

Please guide me.

Grace


回答1:


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



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/1374137/how-to-query-data-in-sharepoint-from-multiple-lists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!