Question

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"

Was it helpful?

Solution

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>";
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top