Saturday 20 August 2011

CAML for Yes\No Column Types in Sharepoint


An example to use Yes\No Column Type in CAML\SPquery
Lets look at the example. Below is the Query to Retrieve all the Items from a list where a Yes\NO type Field named "enable" is "Yes".

// Create a SPQuery Object
SPQuery CheckBoxQuery = new SPQuery();
CheckBoxQuery .Query = “<where><eq><fieldref Name=\ ”enable\” />
<value Type=\ ”bit\”>1</Value>
</Eq></Where>”;

//Get the List
SPList myList = myWeb.Lists["ListName"];

//Get the Items using Query
SPListItemCollection ResultItems = myList.GetItems(CheckBoxQuery);

Ads by Google

No comments:

Post a Comment