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

Declarative Relations incorrect resultset

1 Answer 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
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">
            <DetailTables>
                <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" EnableHierarchyExpandAll="true" Width="100%" DataKeyNames="Asset_Id">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="Asset_Id" MasterKeyField="Asset_Id" />
                    </ParentTableRelation>
                    <Columns>
 
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>

And my DataSources:

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


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
0
Radoslav
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:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarative-relations/defaultcs.aspx
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.

Regards,
Radoslav
Telerik
 

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.

 
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or