首页 > 解决方案 > 将项目添加到列表时,我收到错误 Invalid data has been used to update the list item。您尝试更新的字段可能是只读的

问题描述

我正在使用客户端对象模型来更新 SharePoint 上的列表。

列表很简单,只有 3 列([Title]、[Author]、[Year Published])

【标题】为默认添加的标准栏,

[作者] 是我自己的列,它是一个字符串字段(它不指向用户,它只是纯文本)

和 [发布年份] 发布是一个数字。

所有字段都标记为必填项。

string strUrl = "http://server/sites/training";
using (SPSite oSite = new SPSite(strUrl))
{
    using (SPWeb oWeb = oSite.OpenWeb())
    {
        SPList list = oWeb.Lists["Books"];
        SPListItem book = list.AddItem();
        book["Title"] = "SQL Server Internals";
        book["Author"] = "Mc Fredy";
        book["Year Published"] = 2015;
        book.Update();
    }
}

我得到例外book.Update();

无效数据已用于更新列表项。您尝试更新的字段可能是只读的。

我查看了我在网上找到的所有内容,但没有找到任何答案。请指教。

标签: sharepointsharepoint-clientobjectsplistitem

解决方案


Author是内部 Sharepoint 字段,其中包含有关谁创建了记录(显示名称Created By)的信息,您无法更改它。查看帖子以找出您的字段的内部名称并尝试使用它。


推荐阅读