System.Web.UI.WebControls.GridView.SelectedValue Property

Gets the data key value of the selected row in a System.Web.UI.WebControls.GridView control.

Syntax

[System.ComponentModel.Browsable(false)]
public object SelectedValue { get; }

Value

Documentation for this section has not yet been entered.

Remarks

When the GridView.DataKeyNames property is set with a comma-separated list of field names that represent the primary key of the data source, the System.Web.UI.WebControls.GridView control automatically creates a System.Web.UI.WebControls.DataKey object for each row in the control using the value or values of the specified field or fields. The System.Web.UI.WebControls.DataKey objects are then added to the control's GridView.DataKeys collection. Normally, the GridView.DataKeys property is used to retrieve the System.Web.UI.WebControls.DataKey object for a specific data row in the System.Web.UI.WebControls.GridView control. However, if you just need to retrieve the System.Web.UI.WebControls.DataKey object of the currently selected row, you can simply use the GridView.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 GridView.SelectedValue property.

If you are creating a System.Web.UI.WebControls.ControlParameter object and want to access a key field other than the first field, use the GridView.SelectedDataKey property. For an example, see GridView.SelectedDataKey.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0