SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a webpart that queries an sp list. my list contains two fields (title, tip).

title = is a single text line and
tip = a yes/no check box

currently in my code, i am calling all items in the list:

var query = CamlQuery.CreateAllItemsQuery();

I'd like to modify it to call only items where tip is equal to "yes"

share|improve this question
up vote 1 down vote accepted

This should do the trick:

CamlQuery caml = new CamlQuery();
caml.ViewXml = "<View><Query><Where><Eq><FieldRef Name=\"tip\" /><Value Type=\"Boolean\">1</Value></Eq></Where></Query></View>";
share|improve this answer
It should work except the double quotes inside the string should be single or escaped. – Alex Angas Mar 1 '11 at 23:09
Thanks for catching that Alex! I updated my answer. – SharePoint Wrangler Mar 2 '11 at 0:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.