I could do this by looping through various list\libraries in my site but since i only wanted to get the items or say item Titles, i choose to use SPSitedataquery with viewfields as 'Title'. Here if you do not specify the Lists tag you can retrieve items from the whole site as a Datatable.
An example -
SPSiteDataQuery query = new SPSiteDataQuery();
query.ViewFields = "<FieldRef Name='Title' />";
query.Query = "<Where><Contains>" +
"<FieldRef Name='Title' /><Value Type='text'></Value>"+
"</Contains></Where>";
query.Webs = "<Webs Scope='SiteCollection' />";
DataTable dt = SPContext.Current.Web.GetSiteData(query);
Ads by Google
No comments:
Post a Comment