修改ListItem时出现Error: Invalid data has been used to update the list item. The field you are trying to update may be read only.

执行以下代码时:

SPSite site = new SPSite("http://sharepoint");

SPWeb web = site.OpenWeb();

SPListItem listItem = web.Lists["test_list"].Items[0];

listItem["Title"] = "new Title";

listItem.Update(); // this call will error out

解决办法:

修改 listItem.Update();

改为使用

listItem.SystemUpdate(false);

posted @ 2013-01-17 09:52  Star★  阅读(231)  评论(0编辑  收藏  举报