May 2008

Add choices to Sharepoint Multi-Choice Field

Setting field values of a list item in SharePoint is easy.  But when it comes to Multi-Choice fields, the code is a big different.  The following code shows how values can be added to a multi-choice field.

 

SPFieldMultiChoice choiceField = (SPFieldMultiChoice)myWeb.Fields["choiceFieldName"];

choiceField.Choices.Add("Value");

//Set PushChangesToLists to true if automatic update of List or Content types is required

choiceField.PushChangesToLists = false; 

choiceField.Upate();

by Niral on Mon, 19/05/2008 - 12:21pm   •  

Use CAML Query to Read Data from lists or Libraries

One way to read the data from a list or a library is to iterate through it using the items collection of the list or library. But this is not the most efficient way to do it, specially if only few items are needed from this list.

Enter CAML Queries.

The following is the example query

 

<Where>

  <Eq>

    <FieldRef Name="Title" />

      <Value Type="Text">title</Value>

  </Eq>

</Where>

by Niral on Mon, 19/05/2008 - 10:41am   •