This is a migrated thread and some comments may be shown as answers.

On setting gridview.SelectedItem programmatically its not resetting it to correct view

1 Answer 140 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chaitali
Top achievements
Rank 1
Chaitali asked on 26 Sep 2011, 12:31 PM
Hi,

I have a WPF radgridview, on a particular event (say button click) I want to change the selection on the grid to a different row based on some parameters. The grid is bound to a datatableview. I am setting it as

grid.SelectedItem = ((

 

DataView)grid.ItemsSource).Table.Rows[count];

 

 

grid.CurrentItem = ((

 

DataView)grid.ItemsSource).Table.Rows[count];

 

 

grid.BringIndexIntoView(count);


where count is the index of the row I want to select. Can you please tell me how to do it.

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 26 Sep 2011, 04:17 PM
Hello Chaitali,

Your approach of setting the SelectedItem property is good. However if you use  a view of the table, then you should set the selected item to a row from the view (DataRowView) , not from the table (DataRow).

Regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Chaitali
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or