Access a value using SelectedIndexChanged() event when a row in a GridView control is selectedThere are many instances when the value in a cell is required. For example, when we need to display more information about the selected row. This example demonstrates how access a value in a GridView cell from the selected row using SelectedIndexChanged() event.
In the given code, the method 'OnSelectedIndexChanged' of the GridView control is assigned to the event handler ItemsGridView_SelectedIndexChanged.
The SelectedIndexChanged event is raised when a row's Select button is clicked. We use the SelectedIndexChanged eventhandling method to display the currently selected row. Using the SelectedRow property, we get the currently selected row in the gridView control. Then, we access the data in the cells of the row using the statement:
The above statement displays the value in the third cell of the row.
The following code is the event handler for the SelectedIndexChanged event.
Become an Expert
People also viewed: Create your own ERP Software using ASP Core>>