Initialize DataRow object with DataGridView Selected row

Go To StackoverFlow.com

1

Window c# Desktop Application

I want to initialize a DataRow object with the selected row of DataGrdView.

Is it possible if yes then how?

I am writting the followind code and it is giving compilation error.

DataRow dr = (DataRow)DataGridView1.SelectedRows[0];

Thanks

2012-04-04 06:41
by Tarun Tak


2

Try this:

DataRow dr = (DataGridView1.SelectedRows[0].DataBoundItem as DataRowView).Row;
2012-04-04 06:58
by Dummy01


1

try this

DataRow dr = (dataGridView1.SelectedRows[0].DataBoundItem as DataRowView).Row;
2012-04-04 06:58
by Prakash
According to my browser you were 17 secs faster than me : - Dummy01 2012-04-04 07:00
Ads