List.GetItemById メソッド (Int32)
Returns the list item with the specified list item identifier.
名前空間: Microsoft.SharePoint.Client
アセンブリ: Microsoft.SharePoint.Client.Silverlight (Microsoft.SharePoint.Client.Silverlight.dll 内); Microsoft.SharePoint.Client.Phone (Microsoft.SharePoint.Client.Phone.dll 内) Microsoft.SharePoint.Client (Microsoft.SharePoint.Client.dll 内)
構文
'宣言
Public Function GetItemById ( _
id As Integer _
) As ListItem
'使用
Dim instance As List
Dim id As Integer
Dim returnValue As ListItem
returnValue = instance.GetItemById(id)
public ListItem GetItemById(
int id
)
パラメーター
id
型: System.Int32Specifies the list item identifier.
戻り値
型: Microsoft.SharePoint.Client.ListItem
Returns a ListItem representing the list item with the specified list item identifier.
例外
例外 | 条件 |
---|---|
[System.ArgumentException] | List item does not exist. Error code: -2147024809. |
[System.UnauthorizedAccessException] | The current user has insufficient permissions. Error code: -2147024891. |
例
This code example gets a list item with a specified identifier.
using System;
using Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointFoundation.Samples
{
class List_getItemByIdExample
{
static void Main()
{
string siteUrl = "http://MyServer/sites/MySiteCollection";
ClientContext clientContext = new ClientContext(siteUrl);
Web site = clientContext.Web;
List targetList = site.Lists.GetByTitle("Announcements");
// Get the list item from the Announcements list whose Id is 4.
// Note that this is the ID of the item in the list, not a reference to its position.
ListItem targetListItem = targetList.GetItemById(4);
// Load only the title.
clientContext.Load(targetListItem,
item => item["Title"]);
clientContext.ExecuteQuery();
Console.WriteLine("Request succeeded. \n\n");
Console.WriteLine("Retrieved item is: {0}", targetListItem["Title"]);
}
}
}