I have radGrid1 and inside radGrid1 pageView and Tabs with 2 more radGrid2 and ragGrid3.
In edit mode radGrid2 and radGrid3 shown.
in radGrid2 and radGrid3 users can add new items however I ran into the issue where I can't get the keys from radGrid1 .
Could you help me?
In edit mode radGrid2 and radGrid3 shown.
in radGrid2 and radGrid3 users can add new items however I ran into the issue where I can't get the keys from radGrid1 .
Could you help me?
3 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Nov 2013, 04:58 AM
Hello,
Thanks,
Jayesh Goyani
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AllowPaging="true" OnItemCommand="RadGrid1_ItemCommand"> <MasterTableView DataKeyNames="CustomerID"> <NestedViewTemplate> <asp:Panel runat="server" ID="Panel1" Visible="true"> <telerik:RadTabStrip runat="server" ID="TabStrip1" MultiPageID="Multipage1" SelectedIndex="0"> <Tabs> <telerik:RadTab runat="server" Text="Page 1" PageViewID="PageView1"> </telerik:RadTab> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false"> <telerik:RadPageView runat="server" ID="PageView1"> <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="true" PageSize="5" OnNeedDataSource="RadGrid2_NeedDataSource" /> </telerik:RadPageView> </telerik:RadMultiPage> </asp:Panel> </NestedViewTemplate> </MasterTableView></telerik:RadGrid>protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { RadGrid1.DataSource = "YourDataSOurce"; } protected void RadGrid2_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { GridDataItem parentItem = ((sender as RadGrid).NamingContainer as GridNestedViewItem).ParentItem as GridDataItem; string strID = parentItem.GetDataKeyValue("ID").ToString(); //Access your Key here (sender as RadGrid).DataSource = "YourDataSource"; } protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.ExpandCollapseCommandName && !e.Item.Expanded) { GridDataItem parentItem = e.Item as GridDataItem; RadGrid grid = parentItem.ChildItem.FindControl("RadGrid2") as RadGrid; grid.Rebind(); } }Thanks,
Jayesh Goyani
0
Borislava
Top achievements
Rank 1
answered on 14 Nov 2013, 12:35 PM
I need for Grid2 on InsertCommand event. Also my Grid2 inside RadPageView.
I have try your examples and it's not working in my case
I have try your examples and it's not working in my case
0
Princy
Top achievements
Rank 2
answered on 14 Nov 2013, 01:01 PM
Hi,
Please try the following code snippet to access the DataKeyValue of the parent-table in the Inner Radgrid.
C#:
Thanks,
Princy
Please try the following code snippet to access the DataKeyValue of the parent-table in the Inner Radgrid.
C#:
protected void RadGrid2_InsertCommand(object sender, GridCommandEventArgs e){ if (e.Item is GridEditableItem) { GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem; RadGrid innergrid = (RadGrid)insertItem.OwnerTableView.OwnerGrid; GridNestedViewItem nestedItem = (GridNestedViewItem)innergrid.NamingContainer; GridDataItem parentitem = (GridDataItem)nestedItem.ParentItem; string value= parentitem.GetDataKeyValue("DataKeyColumnName").ToString();// Access Parent table DtakeyValue }}Thanks,
Princy