Questions tagged [spquery]

SPQuery represents a query in a SharePoint list view

SPQuery represents a query in a SharePoint list view. Collaborative Application Markup Language (CAML) can be used to define the query.

Example:

SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb
SPList oList = oWebsiteRoot.Lists["Tasks"];

SPQuery oQuery = new SPQuery();
oQuery.Query = "<Where><Eq><FieldRef Name='Status'/>" + 
               "<Value Type='Text'>Completed</Value></Eq></Where>";

SPListItemCollection collListItems = oList.GetItems(oQuery);

foreach (SPListItem oListItem in collListItems)
{
    Response.Write(SPEncode.HtmlEncode(oListItem["Title"].ToString()) + 
        "<BR>");
}

MSDN - SPQuery

39 questions
0
votes
1 answer

Simple SPQuery issue

I cant get this simple SPQuery working. It does not return any items. Although my document library has 5 items with Modified date as 22/08/2013 12:46 Please help me, where I am getting it wrong ? string SPquery = @"
Chan
  • 19
  • 4
0
votes
0 answers

SPSiteDataQuery with operator

First of all... the query works. With SPQuery it does. The query yields exactly one result (as expected!). However as soon as I use SPSiteDataQuery (and I need to) it yields two results. I realized if I don't use but instead (works in cases where…
lapsus
  • 2,915
  • 2
  • 32
  • 61
0
votes
1 answer

Using IN Element with other Elements in SPQuery

I'm trying to retrieve items from list using this Query: query.Query = @" " +…
Enam
  • 1,268
  • 1
  • 9
  • 16
0
votes
2 answers

quick way to access splistitem in different list?

I have 2 lists: listA and listB listA has 2 fields: Title (text) PortalID (text) listB has 3 fields: Title (text), listAField(lookup to listA Title field) UserID (text) I have a UserID value and I need a quick way to get PortalID value. Currently…
pirmas naujas
  • 180
  • 1
  • 1
  • 13
0
votes
1 answer

Dynamic SPQuery

I want to discuss a scenario here: I want to build a search criteria by using dynamic SPQuery. On my application page, I have 2 textboxes, 2 comboboxes and a people picker Control. Depending on users, which Control's values they use to view the…
SPBeginer
  • 733
  • 3
  • 14
  • 29
0
votes
3 answers

How do I get recurring SharePoint Calendar List Items

Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence should work. However, with the following I only get 3 items in the returned list collection vs. the 3 items and the re-occurrences, all of which fall…
Marc
  • 1,178
  • 1
  • 18
  • 31
-1
votes
2 answers

SPQuery search doesn't work with "BeginsWith"

So, my problem is that my knowledge of CAML and Sharepoint is very poor. Question: I need SPQuery for building query search, search text I have from textbox. I expect that my query returns me item(s) (for example, I type in textbox "Jo" and query…
Viaches
  • 143
  • 1
  • 16
-1
votes
3 answers

SPQuery calculated fields filter does not work in SharePoint 2007/2010

I have a calculated field in my list and I am trying to use filter on this field. For some reason, the following query always returns all items instead of a filtered item collection: var spQuery = new SPQuery { Query =…
Moon
  • 33,439
  • 20
  • 81
  • 132
-1
votes
1 answer

SPQuery versus generic list in Sharepoint

I need to traverse through a sharepoint list and get a count of some of the column values. for eg, in office(col1), if Name(Col2), Smith(Val2) is present twice then the count=2. I have to create a webpart that displays these counts. It looks…
1 2
3