Update Sharepoint List Item

前端 未结 4 935
耶瑟儿~
耶瑟儿~ 2020-12-15 00:31

I got following error...

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.SharePoint.SPListItem.get

4条回答
  •  伪装坚强ぢ
    2020-12-15 01:14

    Try calling Update () on the list before getting the UniqueID

     SPList list = web.Lists["ListName"]; // 2        
     SPListItem item = list.Items.Add();
     item["Title"] = "Test";
     item.Update ();
     list.Update ();
     Guid itemId = item.UniqueId;
    

提交回复
热议问题