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

[Solved] Grid.SelectedItem always null

3 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anan
Top achievements
Rank 1
Anan asked on 19 Dec 2009, 01:12 AM
Hello

I am using the Dec 09 version of grid. I have a nested grid which has hyperlink button as one of the column. On its click even i am trying to get the parent row which got expanded using grid.SelectedItem. Its always null. How do i get parent row which got expanded?

Thanks

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 19 Dec 2009, 06:39 AM
Hello Anil Kumar,

Click of a hyperlink button in child grid will not select any row - parent or child. You can however get parent row using our powerful extension methods:

...
var parentGrid = ((HyperlinkButton)sender).ParentOfType<GridViewDataControl>();
var expandedRow = parentGrid.ParentRow;
...

DataContext of expandedRow in your data object.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anan
Top achievements
Rank 1
answered on 19 Dec 2009, 03:36 PM
Hello

Thanks for you reply...what assembly do i need to add to get ParentOfType method because i dont see it in my intellisense. Also does it give me the parent row which contains the child row and hyperlinkbutton?

Thanks
0
Vlad
Telerik team
answered on 21 Dec 2009, 06:41 AM
Hello Anil Kumar,

You need to register Telerik.Windows.Controls namespace.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Anan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Anan
Top achievements
Rank 1
Share this question
or