对象的当前状态使该操作无效 or SPListItem Update Operation is not valid due to the current state of the object
2008-10-15 18:19
681 查看
在提升权限后对MOSS的list的字段进行更新,出现:对象的当前状态使该操作无效
SPSecurity.RunWithElevatedPrivileges,这个是需要在new SPSite(...)的时候才会去提升权限, 提升的权限是对SPSite, SPWeb的
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
。。。
}
}
});
改为:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = new SPSite("http://localhost/")
SPWeb web = site.OpenWeb()
});
SPList list = web.Lists["字段名"];
SPListItemCollection items = list.Items;
。。。。
item.Update();
就可以了
SPSecurity.RunWithElevatedPrivileges,这个是需要在new SPSite(...)的时候才会去提升权限, 提升的权限是对SPSite, SPWeb的
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
。。。
}
}
});
改为:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite site = new SPSite("http://localhost/")
SPWeb web = site.OpenWeb()
});
SPList list = web.Lists["字段名"];
SPListItemCollection items = list.Items;
。。。。
item.Update();
就可以了
相关文章推荐
- 对象的当前状态使该操作无效 or SPListItem Update Operation is not valid due to the current state of the object
- SPListItem Update Operation is not valid due to the current state of the object(对象的当前状态使该操作无效。)
- MOSS: SPListItem.Update() throws error Operation is not valid due to the current state of the object.
- Web API,Web Service SharePoint对象操作报Operation is not valid due to the current state of the object解决方案
- System.InvalidOperationException: Operation is not valid due to the current state of the object.
- 'Operation is not valid due to the current state of the object' error during postback
- Operation is not valid due to the current state of the object.
- bug:"Operation is not valid due to the current state of the object."
- “Operation is not valid due to the current state of the object.”
- Operation is not valid due to the current state of the object.
- bug:Operation is not valid due to the current state of the object.
- URL-encoded form data is not valid ,Operation is not valid due to the current state of the object
- [转]error - Operation is not valid due to the current state of the object.
- Operation is not valid due to the current state of the object.
- Error occurred in deployment step ‘Activate Features’: Operation is not valid due to the current state of the object
- Operation is not valid due to the current state of the object.
- Error occurred in deployment step 'Add Solution': Operation is not valid due to the current state of the object.
- 关于 error: Operation is not valid due to the current state of the object。
- Operation is not valid due to the current state of the object.
- Operation is not valid due to the current state of the object