Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

1 Answer 1

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
1  
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

 
discard

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