RadGrid Parent/Child and ObjectDataSource

1 posts, 0 answers
  1. Leszek
    Leszek avatar
    22 posts
    Member since:
    Jul 2012

    Posted 13 Sep 2017 Link to this post

    Hi,

    I have a typical master/child RadGrid:

    <telerik:RadGrid ID="RadGridParent"
        AutoGenerateColumns="false"
        DataSourceID="ObjectDataSourceParent"
        runat="server">
        <MasterTableView
            DataSourceID="ObjectDataSourceParent"
            DataKeyNames="Id"
            Name="ParentGrid"
            CommandItemDisplay="Top"
            HierarchyDefaultExpanded="true"
            EnableHierarchyExpandAll="true"
            ShowFooter="false">
            <CommandItemSettings ShowAddNewRecordButton="false" />
            <DetailTables>
                <telerik:GridTableView
                    DataSourceID="ObjectDataSourceChild"
                    DataKeyNames="Id"
                    Name="ChildGrid"
                    CommandItemDisplay="Top"
                    EditMode="InPlace"
                    ShowFooter="false"
                    HierarchyDefaultExpanded="true"
                    runat="server">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="ParentId" MasterKeyField="Id"></telerik:GridRelationFields>
                    </ParentTableRelation>
                    <Columns>
                    ...
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:ObjectDataSource ID="ObjectDataSourceParent" runat="server"
        SelectMethod="RetrieveList">
        <SelectParameters>
            <asp:QueryStringParameter Name="Id" querystringfield="id" />
        </SelectParameters>           
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSourceChild" runat="server"
        SelectMethod="RetrieveList">
        <SelectParameters>
            <asp:Parameter Name="parentId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>

     

    The problem is with the following line:

    <asp:Parameter Name="parentId" Type="Int32" />

    I'd like to specify the parentId of the corresponding parent record. How can I do that?

     

    Thanks,

    Leszek

     

Back to Top