SPWeb.GetListItemFields method

Gets the list item that is associated with the specified server-relative URL, returning data for only the specified fields.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPListItem GetListItemFields(
	string strUrl,
	params string[] fields


Type: System.String

The server-relative URL, such as "/sites/MySite/Shared Documents/MyDocument.docx".

Type: []

The names of the fields for which values are returned in the list item.

Return value

Type: Microsoft.SharePoint.SPListItem
The list item.


fields or strUrl is null .

If fields is an empty array, this method does not return a value for any of the fields for the list item.

This method only gets the values for the specified fields in the list item. To get a list item based on a list item ID, use the GetItemByIdSelectedFields(Int32, []) method.

The following example is a console application that fetches a list item by specifying a URL and an array of field names. After the item is retrieved, the application prints the field values to the console.

using System;
using Microsoft.SharePoint;

namespace Test
   class ConsoleApp
      static void Main(string[] args)
         using (SPSite site = new SPSite("http://localhost"))
            using (SPWeb web = site.OpenWeb())
               // Build a server-relative Url for a list item.
               string itemUrl = web.RootFolder.ServerRelativeUrl;
               itemUrl += "_catalogs/masterpage/default.master";

               // Make a list of fields to fetch.
               string[] itemFields = 

               // Get the list item.
               SPListItem item = web.GetListItemFields(itemUrl, itemFields);

               // Print the values to the console.
               foreach (string fieldName in itemFields)
                  Console.WriteLine("{0} = {1}", fieldName, item[fieldName]);
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Text
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("http://localhost")
            Using web As SPWeb = site.OpenWeb()

                If web.IsMultilingual Then
                    Dim sb As New StringBuilder()
                    Dim sep As String = ", "

                    Dim cultures As IEnumerable(Of CultureInfo) = web.SupportedUICultures

                    For Each culture As CultureInfo In cultures

                    Dim str As String = sb.ToString().Trim(sep.ToCharArray())
                    Console.WriteLine("Supported cultures: {0}", str)
                End If
                Console.WriteLine("Default culture: {0}", web.UICulture.Name)
            End Using
        End Using
        Console.WriteLine(vbCrLf + "Press ENTER to continue....")
    End Sub
End Module