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

How to access the data fields in a parent RadGrid from a child RadGrid's event?

2 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tayyab
Top achievements
Rank 1
Tayyab asked on 10 Sep 2013, 08:56 PM
For a nested RadGrid, how do I access the GridDataItem in a parent Radgrid if I am in a click event that was fired off in the child grid.
e.g.,

<telerik:RadGrid ID="TelerikRadGrid1" runat="server" ....>
   <MasterTableView ....>
         <Columns>
               <telerik:GridBoundColumn DataField="CustomerID1DataField" HeaderText="CustomerID1HeaderText" UniqueName="Customer1UniqueName" Visible="false"    />
       </Columns>
                 <NestedViewTemplate>
                         <div>
                              <telerik:RadGrid ID="TelerikRadGrid2" runat="server" ..... >
                                      <MasterTableView>
                                                <Columns>
<telerik:GridTemplateColumn HeaderText="Update" ColumnGroupName="Action" AllowFiltering="false"><HeaderStyle Width="40px" />
                                          <ItemTemplate>
                                            <asp:LinkButton ID="MatchButton" runat="server" Text="Match" OnClientClick="MatchConfirm()" OnClick="MatchButton_Click" />
                                           </ItemTemplate>
                                  </telerik:GridTemplateColumn>

                                                       <telerik:GridBoundColumn DataField="CustomerID2DataField" HeaderText="CustomerID2Text" UniqueName="CustomerID2Unique" Display="false"></telerik:GridBoundColumn>
                                                  </Columns>
                                      </MasterTableView>
                               </telerik:RadGrid>
                            </div>
                   </NestedViewTemplate>
           </MasterTableView>
</telerik:RadGrid>

public void MatchButton_Click(object sender, EventArgs e)
{
// How do I access the "CustomerID1DataField" in TelerikRadGrid1, from this event?
}


2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Sep 2013, 04:35 AM
Hello,

public void MatchButton_Click(object sender, EventArgs e)
    {
        LinkButton MatchButton = sender as LinkButton;
        GridNestedViewItem item = MatchButton.NamingContainer as GridNestedViewItem;
        GridDataItem parentItem = item.ParentItem as GridDataItem;
        string str = parentItem["Customer1UniqueName"].Text;
           // Access CustomerID1DataField value here
    }


Thanks,
Jayesh Goyani
0
Tayyab
Top achievements
Rank 1
answered on 11 Sep 2013, 11:18 PM
Thanks, Jayesh!
Tags
Grid
Asked by
Tayyab
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Tayyab
Top achievements
Rank 1
Share this question
or