Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SP2013 CSOM C更新列表_C#_Sharepoint_Sharepoint 2013_Csom - Fatal编程技术网

C# SP2013 CSOM C更新列表

C# SP2013 CSOM C更新列表,c#,sharepoint,sharepoint-2013,csom,C#,Sharepoint,Sharepoint 2013,Csom,很好,没有错误。但名单没有更新。我做错了什么?删除最后一个ctx.Loaditems,因为您没有将更新发送到sharepoint,而是重新加载items值 ClientContext ctx = new ClientContext(Site); ctx.Credentials = new NetworkCredential(userName, passWord, "dmz"); List list = ctx.Web.Lists.GetByTitle(SpList)

很好,没有错误。但名单没有更新。我做错了什么?

删除最后一个ctx.Loaditems,因为您没有将更新发送到sharepoint,而是重新加载items值

ClientContext ctx = new ClientContext(Site);
ctx.Credentials = new NetworkCredential(userName, passWord, "dmz");               
List list = ctx.Web.Lists.GetByTitle(SpList);
ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items); // loading all the fields              
ctx.ExecuteQuery();
foreach (var item in items)
{
    if (((FieldUrlValue)(item["VideoSetExternalLink"])).Url.ToString() != VideoURL)
    {
        ((FieldUrlValue)(item["VideoSetExternalLink"])).Url = vp.VideoURL;
        item.Update(); 
    }
}
ctx.Load(items);
ctx.ExecuteQuery();

我通过创建一个FieldUrlValue对象并赋值,然后修改对象,然后将其传递回item,解决了这个问题。例如:FieldUrlValue va=FieldUrlValueitem[VideoSetExternalLink];va.Url=vp.VideoURL;项目[VideoSetExternalLink]=va;谢谢你的帮助。
ClientContext ctx = new ClientContext(Site);
ctx.Credentials = new NetworkCredential(userName, passWord, "dmz");               
List list = ctx.Web.Lists.GetByTitle(SpList);
ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items); // loading all the fields              
ctx.ExecuteQuery();
foreach (var item in items)
{
    if (((FieldUrlValue)(item["VideoSetExternalLink"])).Url.ToString() != VideoURL)
    {
        ((FieldUrlValue)(item["VideoSetExternalLink"])).Url = vp.VideoURL;
        item.Update(); 
    }
}
ctx.ExecuteQuery();
ClientContext ctx = new ClientContext(Site);
ctx.Credentials = new NetworkCredential(userName, passWord, "dmz");               
List list = ctx.Web.Lists.GetByTitle(SpList);
ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery());
ctx.Load(items); // loading all the fields              
ctx.ExecuteQuery();
foreach (var item in items)
{
    if (((FieldUrlValue)(item["VideoSetExternalLink"])).Url.ToString() != VideoURL)
    {
        FieldUrlValue va = ((FieldUrlValue)(item["VideoSetExternalLink"]));
        va.Url = vp.VideoURL;
        item["VideoSetExternalLink"] = va;
        item.Update(); 
    }
}
ctx.Load(items);
ctx.ExecuteQuery();

This is how i Fixed the issue.