Gets the data key value of the selected row in a GridView control.
Assembly: System.Web (in System.Web.dll)
When the DataKeyNames property is set with a comma-separated list of field names that represent the primary key of the data source, the GridView control automatically creates a DataKey object for each row in the control using the value or values of the specified field or fields. The DataKey objects are then added to the control's DataKeys collection. Normally, the DataKeys property is used to retrieve the DataKey object for a specific data row in the GridView control. However, if you just need to retrieve the DataKey object of the currently selected row, you can simply use the SelectedDataKey property as a shortcut. As a further shortcut, you can directly determine the data key value of the first key field of the selected row by using the property.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.