Accessing data-bound objects directly through row objects is useful when you do not have direct access to the data source containing the objects.
In this Snippet we will learn how we can access object bound to DataGridView Row. DataGridViewRow.DataBoundItem Property is the key by this property we can get our custom object quite easily.
Getting DataRow From Row:
Assuming we bound an ordinary DataTable and DataGridViewRow is current row.
DataRow row = ((DataRowView)DataGridViewRow.DataBoundItem).Row
Getting Object Bound From Row:
Assuming we bound List of Customer objects to DataGridView and DataGridViewRow is current row.
Customer cust = DataGridViewRow.DataBoundItem as Customer;