Represents the primary key field or fields of a record in a data-bound control.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|IsTrackingViewState||Gets a value indicating whether the object is tracking its view-state changes.|
|Item[Int32]||Gets the value of the key field at the specified index from a object.|
|Item[String]||Gets the value of the key field with the specified field name from a object.|
|Value||Gets the value of the key field at index 0 in the object.|
|Values||Gets an IOrderedDictionary object that contains every key field in the object.|
|Equals(DataKey)||Determines whether the specified array is equal to the current data key.|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|LoadViewState||Loads the previously saved view state of the object.|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|SaveViewState||Saves the current view state of the object.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|TrackViewState||Marks the starting point at which to begin tracking and saving view-state changes to the object.|
|IStateManager::IsTrackingViewState||Gets a value indicating whether the object is tracking its view-state changes.|
|IStateManager::LoadViewState||Infrastructure. Loads the previously saved view state of the object.|
|IStateManager::SaveViewState||Infrastructure. Saves the current view state of the object.|
|IStateManager::TrackViewState||Infrastructure. Marks the starting point at which to begin tracking and saving view-state changes to the object.|
The class is used to represent the primary key for a record in a data-bound control. The primary key for a record can be composed of one of more fields from the data source. Although the class is not a collection, it can store multiple key field values. The key field values are populated when one of the constructors for the class is called. You can retrieve a key field value from a object in the following ways:
Use the DataKey::Item[Int32] property to retrieve a key field value at a specific index in the object.
Use the DataKey::Item[String] property to retrieve a key field value of a specific field.
Use the Value property to retrieve the value of the key field at index 0 in the object. This property is often used as a shortcut to retrieve the key value of a record when the primary key contains only one field.
In general, objects are automatically generated by data-bound controls when the control's DataKeyNames property is set. The objects contain the values of the key field or fields specified in the DataKeyNames property. Data-bound controls that display a single record at a time (such as DetailsView or FormView) generally store the object for the current record displayed in the DataKey property of the control. Data-bound controls that display multiple records at a time (such as GridView) generally store the objects for each record in the control in a DataKeyArray collection. The DataKeyArray collection is then stored in the DataKeys property of the control.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.