DetailTables and ItemCommand

3 posts, 1 answers
  1. Susan
    Susan avatar
    137 posts
    Member since:
    Jul 2007

    Posted 17 Aug 2008 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Aug 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Susan
    Susan avatar
    137 posts
    Member since:
    Jul 2007

    Posted 18 Aug 2008 Link to this post

    That worked...Thanks!

    Susan
Back to Top