DetailsView.DataKey Property

 

Gets a DataKey object that represents the primary key of the displayed record.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[<BrowsableAttribute(false)>]
abstract DataKey : DataKey with get
[<BrowsableAttribute(false)>]
override DataKey : DataKey with get

Property Value

Type: System.Web.UI.WebControls.DataKey

A DataKey that represents the primary key of the displayed record.

When the DataKeyNames property is set, the DetailsView control automatically creates a DataKey object that represents the key field or fields for the current record. Use the DataKey property to get this DataKey object. This property is commonly used to obtain the keys and their corresponding values for the fields specified in the DataKeyNames property.

System_CAPS_noteNote

As a shortcut, you can also use the SelectedValue property to determine the value of the first key field listed in the DataKeyNames property.

The following code example demonstrates how to use the DataKey property to determine the key field and corresponding value for the current record.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: