0 out of 1 rated this helpful - Rate this topic

SPListItem.Item Property (String)

Gets or sets a field value in the item based on the field’s title, internal name, or static name.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
public override Object this[
	string fieldName
] { get; set; }

Parameters

fieldName
Type: System.String
A string that contains the title, internal name, or static name of the field.

Property Value

Type: System.Object
An object that contains the field value.
Exception Condition
ArgumentException

The field does not exist.

The Item property is an indexer for the SPListItem class.

The runtime will search first through the internal names of the list item’s fields for the specified string before searching the display names.

For information about the field types that are used in SharePoint Foundation and how they relate to .NET Framework types, see the SPListItem class.

Important note Important

To improve performance and optimize the number of SQL Server queries that SharePoint Foundation must execute, use the GetItems method of the SPList class to retrieve items based on the value of their fields. The GetItems method allows you to specify search criteria by passing a Collaborative Application Markup Language (CAML) query through the SPQuery or SPView class. In addition, list performance may be compromised if a list contains an unnecessarily large number of fields.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Internal and static names have problems
Sometimes internal names doesn't work for this method and although list has field with given internal name it throws exception that field is not found. The best way to handle this nasty problem (very hard to detect what's going on) you can write your own extension methods to get and set field values by internal name (practically these extension methods make SPListItem work like said in documentation).