Jeffrey Lewis
Top achievements
Rank 1
Jeffrey Lewis
asked on 19 May 2010, 11:14 AM
How do I get the GridViewRowItem object of the selected row in the RadGrid SelectionChanged event?
4 Answers, 1 is accepted
0
Accepted
Hi Jeffrey Natheniel Lewis,
in your event handler.
Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
What you can do is
var row =
this
.radGridView.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0])
as
GridViewRowItem;
Sincerely yours,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jeffrey Lewis
Top achievements
Rank 1
answered on 20 May 2010, 02:03 AM
Hi Yavor Georgiev,
The value returned from ContainerFromItem is null. I've checked to confirm that e.AddedItems[0] has value in it (of type DataRow).
The following is my code (My ItemsSource is a DataTable):
----------------------------------------------------------------------
DataTable dtFeeds = GetFeeds();
this.radGridFeeds.ItemsSource = dtFeeds;
----------------------------------------------------------------------
private void radGridFeeds_SelectionChanged(object sender, SelectionChangeEventArgs e)
{
var row = this.radGridFeeds.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]) as GridViewRowItem;
}
Please asist. Thanks.
0
Hello Jeffrey,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Please find attached a sample solution. If you still have troubles, please consider preparing a sample solution yourself, along with your Telerik assemblies, that demonstrates the incorrect behavior.
Sincerely yours,Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jeffrey Lewis
Top achievements
Rank 1
answered on 21 May 2010, 02:49 AM
Thank you very much for the solution. My problem is solved.
I have noticed that when the radgrid's IsSynchronizedWithCurrentItem property is true, the first record selected(by default) always returns a null value from ContainerFromItem. To solve this, I've set the IsSynchronizedWithCurrentItem to false, and manually select the default record in the Loaded event.