Solved

CAML Query with Contains not working

Posted on 2011-03-20
4
727 Views
Last Modified: 2012-05-11
I have a list called wraps with 12 items, no matter what I search using the following query, it always returns me the 12 items, so its not working correctly.

I debugged and the variable tag is OK.

  SPSite site = SPContext.Current.Site;
                // get the list
                SPList lstTagList = site.RootWeb.Lists.TryGetList("Wraps");
                if (lstTagList != null)
                {
                    // Try to find the item I want
                    SPQuery query = new SPQuery();
                    query.Query = "<Query><Where><Contains><FieldRef Name='Agenda_x0020_Tags' /><Value Type='Text'>" + tag + "</Value></Contains></Where></Query>";
                    SPListItemCollection foundItems = lstTagList.GetItems(query);
                    DataView dv = new DataView(foundItems.GetDataTable());
                    PagedDataSource page = new PagedDataSource();
                    page.AllowCustomPaging = true;
                    page.AllowPaging = true;
                    page.DataSource = dv;
                    page.PageSize = 10;
                   
                    WrapsRepeater.DataSource = page;
                    WrapsRepeater.DataBind();
0
Comment
Question by:LuisEstebanValencia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
KoenVosters earned 500 total points
ID: 35178417
navdeep maybe read the question?

Luis you are probably using the querybuilder of U2U. You need to remove the <query> tags from your query.
0
 

Author Closing Comment

by:LuisEstebanValencia
ID: 35179102
Navdeep didnt event read the question. He think that just pasting an url would give him the points, you did the homework.

Thank you
0
 
LVL 14

Expert Comment

by:KoenVosters
ID: 35179112
gl at m* ;-)
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question