I have multiple SharePoint lists and want to display data from them on to a gridview control.
Please guide me.
Grace
Your question inspired me to develop a web part that demonstrates:
How to query SharePoint data in the many ways offered by the API, and
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.
Two options that I can think of:
SPSiteDataQuery
Set up a search scope, metadata, and then query your Scope using Enterprise Search SQL and FullTextSqlQuery
With SharePoint 2007 you can use CrossListQueryCache and CrossListQueryInfo. More information here.
Related
This is quite a simple question to ask, hopefully the answer is as straight forward! Can you use a Content Query Webpart on Site Collection A to read data from Site Collection B?
If it's not supports right out of the box, are there some configuration options which you can use to make it happen?
Thanks.
No configuration option will enable you to have a cross site content query webpart.
You can either create a custom web part that will do it or buy one (several options out there, here is one
If you decide to create your own web part, you will easily find code online that will help you. Here is an example.
No, it must be within the same site collection as it uses the SPSiteData query, which works within the site collection
I am trying every option to show List data on a web part and web user control, but I am not finding any code examples on this. What namespace should I import?
I am using WSS 3.0 and I will later upgrade to MOSS 2007. I am aware of the SmartPart project and I can use it in my environment.
Thank you very much for your help.
You should first look at the Data View Web Part (DVWP) to see if that will fit your needs. With some XLST/JavaScript you can get very creative with this.
Data View Web Part Basics
Otherwise you need to understand two things :-
Creating a Basic web part
This is for VS2010/SharePoint 2010 but you will find similar walkthroughs for other versions such as :-
http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c12293/
http://channel9.msdn.com/posts/kmcgrath/Creating-a-Web-Part-for-SharePoint-by-Using-a-Designer/
http://www.codeproject.com/KB/sharepoint/Generic_Webparts.aspx
Accessing SharePoint List data
Then once you've got your basic web part you need to know how to use the object model to open a list and iterate through the items in a list to display the data in whatever funky way you want.
Accessing list items
I am able to access a Site then Lists inside the Site and then List Items inside all the Lists. This works fine when I want to crawl/access all the Items in a Site.
I am keen to know if there is a way through which we can directly access a List in a Site. To elaborate on this :: If I have 1000 sites and 1000 documents then I would have to go through 1999 items at the worst before finding the one I want.
Any help/suggestion on this would be greatly appreciated.
Thanks
Try using an SPSiteDataQuery to get what you need. There are many ways to develop the CAML query you want such as CAML Query Builder.
This is the best way to avoid trolling through all Webs->Lists->ListItems to find items.
I prefer to limit the SPSiteDataQuery to one site collection and call the query for each site collection that is relevant as there are some limitations to the SPSiteDataQuery.
The equivalent for webservices would be the GetListItems in the SiteData webservice
Is it possible to move a MOSS subsite and content to a different site collection using the SharePoint API? For example, I would like to archive a subsite, by moving it from /teamsite/subsite1 to /teamsite/archive/subsite1. I am using MOSS 2007.
Thanks, MagicAndi.
MagicAndi,
The answer is a resounding "yes." The import and export of sites within SharePoint is handled through the Content Deployment API (also known as the PRIME API). This API is responsible for providing the backing to both import/export functionality supplied through STSADM.exe; it also handles the content deployment within MOSS.
A great place to get started with the Content Deployment API is with a series of articles written by Stefan Gossner. Stefan is an escalation engineer for Microsoft, and you'd be hard pressed to find someone more knowledgeable in the practical workings of the PRIME API:
http://blogs.technet.com/stefan_gossner/archive/2007/08/30/deep-dive-into-the-sharepoint-content-deployment-and-migration-api-part-1.aspx
All parts of this six-part series are excellent, and I recommend reading them all. Parts three and four, though, get to some of the specifics of the import and export operations you indicated you'd like to implement.
I hope this helps!
You need to look in to the Content Deployment API, Here is one of the Class Article in the subject.
Which web part and how to configure it to view a list from a different site collection?
Please note that I do not want to view a page but a list. For example view Announcements from a different team site under a seperate site collection.
Thank you in advance for your help.
The Data Form web part available through SharePoint designer can do this.
The Content Query Web Part (CQWP) which is part of the publishing infrastructure (requires MOSS) does not go across site collections.
Re http://www.spelements.com/spanylistview/
The problem with this one is you have to be able to INSTALL it on the server.
If you do not have those permissions, it cannot be used.
Don't bother asking if they can be obtained. They can't.