I've got a Master Grid, with a NestedViewTemplate that has a sub grid in it. I want this sub grid to databind when a row in the Master Grid is expanded. The sub grid's binding method needs the data key from the Master Grid row to bind. I'm having trouble connecting this key to the sub grid, its always 0. I've reviewed the documention for NestedViewTemplates and NestedViewSettings but must still be doing something wrong. The docs for the NestViewTemplates refer to the working demo but it uses a Label to stash the Master Table row key rather than the NestedViewSettings which I'm trying to use. I've have been able to bind the sub grid table using various techniques such as stashing the Master Table row key in the label or using NeedsDataSource. These other methods won't work for me as they want to bind sub grid data for all rows of the master grid when the page is loaded and this is too slow.
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<telerik:RadScriptManager ID="BudgetAdjustmentScriptManager" runat="server" EnablePartialRendering="true"></telerik:RadScriptManager>
<telerik:RadGrid ID="BudgetAdjustmentRadGrid" runat="server" Width="100%" AllowPaging="True" AllowSorting="true" AutoGenerateColumns="False" PageSize="20" DataSourceID="BugetAdjustmentRadGrid_ObjectDataSource"
AlternatingItemStyle-BackColor="#e6e6e6" ShowFooter="True">
<MasterTableView CommandItemDisplay="Top" Width="100%" DataKeyNames="budget_adjustment_master_id" ShowGroupFooter="true" Name="Master">
<Columns>
<telerik:GridEditCommandColumn ButtonType="FontIconButton" UniqueName="Edit"></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="name" HeaderText="Name" UniqueName="name" MaxLength="50" ></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="number" HeaderText="Number" UniqueName="number" readonly="true"></telerik:GridBoundColumn>
</Columns>
<NestedViewSettings DataSourceID="BudgetAdjustmentItem_ObjectDataSource">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="budget_adjustment_master_id" MasterKeyField="budget_adjustment_master_id" />
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate>
<asp:Panel ID="InnerContainer" runat="server" CssClass="viewWrap" Visible="True">
<telerik:RadGrid ID="BudgetAdjustmentItemRadGrid" runat="server" DataSourceID="BudgetAdjustmentDetail_ObjectDataSource" AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false" >
<MasterTableView DataKeyNames="budget_adjustment_master_id, budget_adjustment_detail_id" HierarchyLoadMode="ServerOnDemand" PageSize="10" CommandItemDisplay="Top">
<Columns>
<telerik:GridEditCommandColumn ButtonType="FontIconButton" UniqueName="Edit"></telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="budget_adjustment_detail_id" HeaderText="ID" SortExpression="budget_adjustment_detail_id" UniqueName="budget_adjustment_detail_id" ReadOnly="true"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="budget_adjustment_operation" HeaderText="Operation" SortExpression="budget_adjustment_operation" UniqueName="budget_adjustment_operation" ReadOnly="true"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</asp:Panel>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID="BudgetAdjustmentDetail_ObjectDataSource" runat="server" TypeName="BudgetAdjustmentDetailDAL" SelectMethod="Get" SortParameterName="sort_expression" >
<SelectParameters>
<asp:Parameter Name="budget_adjustment_master_id" Type="Int32" />
<asp:Parameter Name="project_node_master_id" DefaultValue="25" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="BudgetAdjustmentItem_ObjectDataSource" runat="server" TypeName="BudgetAdjustmentMasterDAL" SelectMethod="Get">
<SelectParameters>
<asp:Parameter Name="budget_adjustment_master_id" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="BugetAdjustmentRadGrid_ObjectDataSource" runat="server" TypeName="BudgetAdjustmentMasterDAL" SelectMethod="Get" SortParameterName="sort_expression">
<SelectParameters>
<asp:Parameter Name="project_node_master_id" DefaultValue="33" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</asp:Content>