Get the correct DataTable Row?

  • Thread starter Thread starter R Agam
  • Start date Start date
R

R Agam

Hi

I am using a DataGrid with sorting enabled.
When the user double click on a Row I get the selected index. Now How can I
get the DataTable row corresponding to the selected index?



Thanks,
Ronen
 
Ronen,

If you have the row number, you can pass the row number to the DataView
returned by the DefaultView property on the DataTable. This view is what is
being sorted. The indexer for the view will return the items in the correct
order.

Hope this helps.
 
Hi R Agam

the only way i found is using BindingManagerBase

exp:
BindingManagerBase bm = MyGrid.BindingContext[MyGrid.DataSource,
MyGrid.DataMember];

string Name = ((DataRowView)bm.Current).Row["Name"].ToString();

Using DefaultView it dosn't work for me (with sorting enabled)

string Name =
Dt.DefaultView.Table.Rows[MyGrid.CurrentRowIndex]["Name"].ToString());
 
Back
Top