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 am using managed client object model in sharepoint and I am adding EventDate and on adding that I am catching exception which says Microsoft.SharePoint.SPFieldValueException

if (thisfield.StaticName.ToLower() == "eventdate" 
 || thisfield.StaticName.ToLower() == "enddate")
  newitem.ParseAndSetFieldValue(thisfield.InternalName, spitem[thisfield.StaticName].ToString());

Please let me know what should I do .

Thanks

share|improve this question
    
Here is the line code if (thisfield.StaticName.ToLower() == "eventdate" || thisfield.StaticName.ToLower() == "enddate") newitem.ParseAndSetFieldValue(thisfield.InternalName, spitem[thisfield.StaticName].ToString()); –  RHM Mar 16 '12 at 14:45
add comment

1 Answer 1

Please Follow with this Code

 ClientContext ctx = new ClientContext("http://yoursite");
List list = ctx.Web.Lists.GetByTitle("ListName");
ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items); // loading all the fields
ctx.ExecuteQuery();

foreach(var item in items)
{
    // important thing is, that here you must have the right type
    // i.e. item["Modified"] is DateTime
    item["fieldName"] = newValue;

    // do whatever changes you want

    item.Update(); // important, rembeber changes
}
ctx.ExecuteQuery(); // important, commit changes to the server
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.