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

[Solved] Parent's DataKeyValues in Hierarchy CommandItemTemplate

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
art
Top achievements
Rank 1
art asked on 20 Jul 2009, 10:32 PM
Hi,

I have a RadGrid with Hierarchy. I would like to access the DataKeyValues (parent/master table Key Values) in the DetailTables' <CommandItemTemplate>.

Here is the code snippet,

<DetailTables>
                           <telerik:GridTableView DataKeyNames="DV_Correlation_Detail_ID" DataSourceID="dsrcCorrDetail" HierarchyDefaultExpanded="true" ShowHeader="true" ShowFooter="false"
                                    Width="100%" runat="server" AllowFilteringByColumn="False" CommandItemDisplay="Top" Name="Correlation_Detail" EditMode="InPlace">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="DV_Correlation_ID" MasterKeyField="DV_Correlation_ID" />
                                </ParentTableRelation>
                                <CommandItemTemplate>
                                    <a href="Javascript:showDialog(1,'derived_variable_selection.aspx?CorrID=<%# Eval("DV_Correlation_ID") %>');"><img style="border:0px" alt="Add Independent Variable" src="images/AddRecord.gif" /> Add Independent Variable </a>
                                </CommandItemTemplate>
                               
When I do "Eval()", it did not complain, and it did not return any value, either. How can I get the key value for each hierarchy detail table within CommandItemTemplate?

Any assistance will be very much appreciated.

Thanks,

Arthur W.

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 Jul 2009, 03:34 PM
Hello Art,

To achieve your goal you will need to the following code which implements the required functionality:
<href="Javascript:showDialog(1,'derived_variable_selection.aspx?CorrID
<%# ((GridCommandItem)Container).OwnerTableView.ParentItem.GetDataKeyValue("DV_Correlation_ID").ToString() %>');"><img style="border:0px" alt="Add Independent Variable" src="images/AddRecord.gif" /> Add Independent Variable </a> 

Regards,
Georgi Krustev
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
art
Top achievements
Rank 1
answered on 23 Jul 2009, 04:07 PM
Hi, Georgi,

It worked beautifully. Thanks for your help.

Regards,

Arthur
Tags
Grid
Asked by
art
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
art
Top achievements
Rank 1
Share this question
or