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

Nested Detail Table and LinqDataSource

1 Answer 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gourangi
Top achievements
Rank 1
Gourangi asked on 23 Mar 2009, 06:10 AM
Hi,

I have 3 level nested detail table herarchy like a Locations has multiple branches and each branches has multiple devices.

Now my aspx looks like below.


<telerik:RadGrid ID="grdLocations" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"

 AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateDeleteColumn="True"

 AutoGenerateEditColumn="True" DataSourceID="LinqDataSourceLocations" GridLines="None"

 Skin="Gray">

 <MasterTableView DataSourceID="LinqDataSourceLocations" DataKeyNames="LocationID">

 <DetailTables>

 <telerik:GridTableView runat="server" DataSourceID="LinqDataSourceBranches" DataKeyNames="BranchID">

 <ParentTableRelation>

 <telerik:GridRelationFields MasterKeyField="LocationID" DetailKeyField="LocationID" />

 </ParentTableRelation>

 <DetailTables>

 <telerik:GridTableView runat="server" DataSourceID="LinqDataSourceDevices">

<ParentTableRelation>

<telerik:GridRelationFields DetailKeyField="BranchID" MasterKeyField="BranchID" />

 </ParentTableRelation>

 </telerik:GridTableView>

 </DetailTables>

 </telerik:GridTableView>

 </DetailTables>

 </MasterTableView>

 </telerik:RadGrid>

 <asp:LinqDataSource ID="LinqDataSourceLocations" runat="server" ContextTypeName="InsightDataContext"

 Select="new (LocationName, LocationID)" TableName="LocationMasters">

 </asp:LinqDataSource>

 <asp:LinqDataSource ID="LinqDataSourceBranches" runat="server" ContextTypeName="InsightDataContext"

 Select="new (BranchID, BranchName, LocationID)" TableName="BranchMasters" Where="LocationID == @LocationID">

 <WhereParameters>

 <asp:ControlParameter ControlID="grdLocations" Name="LocationID" PropertyName="SelectedValue"

 Type="Int32" />

 </WhereParameters>

 </asp:LinqDataSource>

 <asp:LinqDataSource ID="LinqDataSourceDevices" runat="server" ContextTypeName="InsightDataContext"

 Select="new (DeviceName, DeviceID, BranchID)" TableName="DeviceMasters" Where="DeviceID == @DeviceID">

 <WhereParameters>

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

<%--<asp:ControlParameter Name="DeviceID" PropertyName="SelectedValue"

 Type="Int32" />--%>

 </WhereParameters>

 </asp:LinqDataSource>

 

Here you can see I have placed 3 LinqDataSources for three tables. Now thing is I could write WHERE parameter for my branches table as I could got grdLocations and which has DataKeys as LocationID. But I could not get its detail table's DataKey value i.e. BranchID for my last LinqDataSource (Inner detail table's datasource control could not get its parent's ID).

What should I do in this?

Thanks & Regards,
Divyesh Chapaneri

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 26 Mar 2009, 09:13 AM
Hi Divyesh Chapaneri,

I think your where clause in the third linq data source should be:

    Where="BranchID == @BranchID" 

and not:

    Where="DeviceID == @DeviceID" 

In any case, the second table is passing a BranchID field to the third linq data source, whereas the latter expects a DeviceID for its where parameter - and this mismtach is bound to fail the third level of the hierarchy.

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Gourangi
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or