DataGrid: get DataRow by index after sorting

  • Thread starter Thread starter Oleg Ogurok
  • Start date Start date
O

Oleg Ogurok

Hi there,

If I have an index of a row in a Winforms DataGrid, how do I get its
underlying DataRow? Since a user can sort rows in grid by some column,
I can't just use one-to-one index mappings between DataGrid rows and
the rows in the DataTable. What's the proper way to get the DataRow?
I'm under 1.1.

Thanks,
-O.
 
Hi there,

If I have an index of a row in a Winforms DataGrid, how do I get its
underlying DataRow? Since a user can sort rows in grid by some column,
I can't just use one-to-one index mappings between DataGrid rows and
the rows in the DataTable. What's the proper way to get the DataRow?
I'm under 1.1.

Thanks,
-O.

There is a DataView between the DataTable and the DataGrid, and the
DataView is what is sorted. If you didn't explicitly create one, then
you can get it from DataTable.DefaultView.

You index into the DataView to get a DataRowView.
 
Back
Top