Programmatically select row in DataGrid

Aug 24, 2009 at 9:12 PM

Hello, I am trying to programmatically select, using C#, a row in a DataGrid bound to a DataTable

 I bind my DataGrid to the populated Database using

dataGrid.ItemsSource = myDataTable.DefaultView;

Now I want to select the nth Row in my DataTable on the DataGrid.

I have tried

dataGrid.SelectedItem = myDataTable.Rows[n];


dataGrid.SelectedIndex = n;

When binding the DataTable the only object created in dataGrid.Items is of type System.Data.DataRowView and it is all read-only.

Is there a way to do this, and is it even possible? Thanks