DataGrid.SelectedIndex Property

 

Gets or sets the index of the selected item in the DataGrid control.

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

[<BindableAttribute(true)>]
abstract SelectedIndex : int with get, set
[<BindableAttribute(true)>]
override SelectedIndex : int with get, set

Property Value

Type: System.Int32

The index of the selected item in the DataGrid control.

Exception Condition
ArgumentOutOfRangeException

The specified index is less than -1.

Use the SelectedIndex property to determine the index of the item selected by the user in the DataGrid control. You can also use this property to programmatically specify which item is selected in the DataGrid control.

To deselect an item in the DataGrid control, set this property to -1.

The following code example demonstrates how to use the SelectedIndex property to determine the index number of the selected item in the DataGrid control. It also shows how to select and deselect an item programmatically.

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

.NET Framework
Available since 1.1
Return to top
Show: