Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Get the Selected DataRow in a DataGridView?

I have a DataTable bound to a DataGridView. I have FullRowSelect enabled in the DGV. Is there a way to get the selected row as a DataRow so that I can get strongly typed access to the selected row's values?

like image 645
Damien Avatar asked May 21 '09 23:05

Damien


People also ask

How can we get selected row data from GridView in ASP NET?

When a row is selected in a GridView control, use the SelectedRow property to retrieve the GridViewRow object that represents that row. This is the same as retrieving the GridViewRow object at the index specified by the SelectedIndex property from the Rows collection.

How do I pass DataGridView selected row value to textbox in another form?

Text = Convert. ToString(frm. DataGridView1[1, row]. Value);


1 Answers

DataRowView currentDataRowView = (DataRowView)dgv1.CurrentRow.DataBoundItem
DataRow row = currentDataRowView.Row
like image 156
stuartd Avatar answered Sep 27 '22 16:09

stuartd