Gets or sets the index of the selected item in a ListView control.
System.Web.Extensions (in System.Web.Extensions.dll)
Public Overridable Property SelectedIndex As Integer
The zero-based index of the selected item in a ListView control. The default is -1, which indicates that no item is currently selected.
Use the SelectedIndex property to determine the index of the currently selected item in a ListView control. You can also use this property to programmatically select an item in the control. (However, if you manually data-bind the ListView control, you might have to handle reading or setting this property manually as well.)
The following example shows how to use the SelectedIndex property to determine whether an item is selected in a ListView control. This code example is part of a larger example provided for the DeleteItem method.
Protected Sub DeleteButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Check if an item is selected to delete it.
If ContactsListView.SelectedIndex >= 0 Then
Message.Text = "No contact was selected."
Return to top
Available since 3.5