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

Selected Row using DataBinding

2 Answers 218 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 23 Apr 2009, 10:29 PM
Can you guys give me an example of selecting a row in the grid using databinding?

My DataContext will have a custom object with two values:

  • Object ItemsSource
  • Int SelectedRow

I want to use updates to the DataContexts to auto update the grid, ItemsSource="{Binding Path=ItemsSource}" works for the data, but i cannot figure out the selected row.

2 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 24 Apr 2009, 12:57 PM
Hi Dmitry,

RadGridView does not have a property selected index but you can, for example, use the SelectedItem property with just a small modification of your data context. In addition to the selected index property you could add a new one called SelectedItem that returns the actual data item data is selected. Once you have that property you can easily bind RadGridView.SelectedItem to DataContext.SelectedItem.
I have prepared a sample application that demonstrates a similar binding scenario. 

Best wishes,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dmitry
Top achievements
Rank 1
answered on 24 Apr 2009, 09:10 PM
Thank you for the sample, I will review it next week, did not get to this one today but its still needed.
Tags
GridView
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Milan
Telerik team
Dmitry
Top achievements
Rank 1
Share this question
or