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

DetailTables and ItemCommand

2 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susan
Top achievements
Rank 1
Susan asked on 17 Aug 2008, 02:18 PM
I have a detail table that shows all the coaches associated with a team. The details table also has a 'delete' column where I can remove that coach from a team. In the grdTeamToCoach_ItemCommand, how do I get the value of the row that is clicked in the detail table (specifically the 'teamtocoachkey')?

Thanks!
Susan

<

MasterTableView Width="100%" DataKeyNames="TeamKey">

<DetailTables>

<telerik:GridTableView Width="100%" runat="server" Name="AssignedCoaches" DataKeyNames="TeamToCoachKey">

<ParentTableRelation>

<telerik:GridRelationFields DetailKeyField="TeamKey" MasterKeyField="TeamKey" />

</ParentTableRelation>

<Columns>

<telerik:GridBoundColumn DataField="CoachAndType"/>

<telerik:GridTemplateColumn HeaderText="Remove" ItemStyle-HorizontalAlign=center>

<ItemTemplate>

<asp:ImageButton CommandName="DeleteRecord" TabIndex=-1 id="ibDelete" imageUrl="../images/delete.png" CausesValidation="False" runat="server" />

</ItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridBoundColumn DataField="TeamToCoachKey" Visible="false"/>

</Columns>

</telerik:GridTableView>

</DetailTables>

<Columns>

<telerik:GridBoundColumn HeaderText="Team and # of Coaches" DataField="TeamAndCount" UniqueName="TeamToCoachKey"/>

<telerik:GridBoundColumn DataField="TeamKey" Visible="false"/>

</Columns>

</MasterTableView>

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Aug 2008, 04:30 AM
Hi Susan,

Try the following code snippet to access the DataKeyValue for the clicked row.

CS:
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "DeleteRecord") 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strKey = item.GetDataKeyValue("TeamToCoachKey").ToString(); 
        } 
    } 



Regards
Shinu.
0
Susan
Top achievements
Rank 1
answered on 18 Aug 2008, 10:29 PM
That worked...Thanks!

Susan
Tags
Grid
Asked by
Susan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Susan
Top achievements
Rank 1
Share this question
or