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

Declarative Relations incorrect resultset

1 Answer 34 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Steven asked on 17 Sep 2014, 03:47 PM
I have a RadGrid with a DetailTables nested inside it.
My design is simple: The RadGrid displays the contents of a table. When a row is expanded, I want to display the audit trail for that record which is saved in another table. 
The relationship is 1 Table_Item to many Table_Item_History records.

Here's my solution thus far:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource1" ShowStatusBar="true"
        AutoGenerateColumns="false" AllowSorting="true" AllowMultiRowSelection="false" GridLines="None">
        <MasterTableView DataKeyNames="Asset_Id" EnableHierarchyExpandAll="true" AllowMultiColumnSorting="true">
                <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" EnableHierarchyExpandAll="true" Width="100%" DataKeyNames="Asset_Id">
                        <telerik:GridRelationFields DetailKeyField="Asset_Id" MasterKeyField="Asset_Id" />

And my DataSources:

<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Asset]"
   <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Asset_History] WHERE ([Asset_Id] = @Asset_Id)"
           <asp:ControlParameter ControlID="RadGrid1" Name="Asset_Id"
               PropertyName="SelectedValue" Type="Object"></asp:ControlParameter>

The resulting behavior is whenever a row is expanded, the child elements are always 0. I've tested the same query in multiple ways in SQL Server and they're working fine. I've tried this with Session Parameters and the results are the same.
Any assistance is appreciated

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 22 Sep 2014, 08:18 AM
Hello Steven,

The described scenario should work with Session parameter as in our online example:
Please check it out and let me know what differs in your case.
Also could you please try expecting the SQL query sent to the SQL server by using the sql profiling tool, like: ExpressProfiler

Looking forward for your reply.


Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question