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

ParentTableRelation not working

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed McCarroll
Top achievements
Rank 1
Ed McCarroll asked on 15 Jun 2010, 07:50 PM
I have a three-level grid, with each level attempting to display a one-to-many relationship in my database.

I think I've correctly set up my and my ParentTableRelation and my DataKeyNames correctly, but the ObjectDataSource is being passed "Nothing" in the SessionParameters.

Here's my grid:

<telerik:RadGrid ID="grdSchedule" 
    AllowMultiRowSelection="false" 
    AutoGenerateColumns="False" 
    GridLines="None" 
    runat="server" 
    ShowFooter="false" 
    ShowGroupPanel="True" 
    ShowStatusBar="false" 
    Skin="Web20" 
    Width="880px">  
    <MasterTableView AllowPaging="True" DataKeyNames="DepartmentId" DataSourceID="dsrDepartments" HierarchyLoadMode="ServerBind" PageSize="3">  
        <Columns> 
            <telerik:GridTemplateColumn UniqueName="CourseDescription">  
                <ItemTemplate> 
                    <table width="100%" style="border-width: 0;">  
                        <tr> 
                            <td align="left" style="border-width: 0;">  
                                <asp:Label ID="lblDepartment" runat="server" 
                                    Text='<%# Eval("DepartmentName") & " (" & Eval("Chairperson") & ", Chairperson)" %>' /> 
                            </td> 
                            <td align="right" style="border-width: 0;">  
                                <asp:Label ID="lblDivision" runat="server" Text='<%# UCase(Eval("DivisionName")) & " DIVISION" %>' /> 
                            </td> 
                        </tr> 
                    </table> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
       <DetailTables> 
            <telerik:GridTableView ClientDataKeyNames="DepartmentId" DataKeyNames="DepartmentId" DataSourceID="dsrCourses" 
                HierarchyLoadMode="ServerBind" runat="server" Width="100%">  
                <ParentTableRelation> 
                    <telerik:GridRelationFields DetailKeyField="DepartmentId" MasterKeyField="DepartmentId" /> 
                </ParentTableRelation> 
                 <DetailTables> 
                    <telerik:GridTableView ClientDataKeyNames="CourseId" DataSourceID="dsrSections" HierarchyLoadMode="ServerBind" 
                        runat="server" Width="100%">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="CourseId" MasterKeyField="CourseId" /> 
                        </ParentTableRelation> 
                        <ItemStyle VerticalAlign="Top" /> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="SectionNumber"  HeaderText="Section"    UniqueName="SectionNumber">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="Instructor"     HeaderText="Instructor" UniqueName="Instructor">  
                                <HeaderStyle HorizontalAlign="Left" /> 
                                <ItemStyle HorizontalAlign="Left" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn                         HeaderText="Dates"      UniqueName="Dates">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                                <ItemTemplate> 
                                    <asp:Label ID="DepartmentNameLabel" runat="server" 
                                        Text='<%# Eval("DateStart", "{0:MMM d}") & " - " & Eval("DateEnd", "{0:MMM d}") %>' /> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn                         HeaderText="Time"      UniqueName="Sessions">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                                <ItemTemplate> 
                                    <asp:Repeater ID="rptSession" runat="server">  
                                        <ItemTemplate> 
                                            <asp:Label ID="lblDayAndTime" runat="server" 
                                                Text='<%# Eval("DayAndTimes") & "&nbsp;" %>' /> 
                                        </ItemTemplate> 
                                    </asp:Repeater> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn                         HeaderText="Room"      UniqueName="Sessions">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                                <ItemTemplate> 
                                    D104  
                                    <br /> 
                                    D104  
                                    <asp:Repeater ID="rptSession" runat="server">  
                                    </asp:Repeater> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridBoundColumn DataField="Enrolled"       HeaderText="Enrolled"   UniqueName="Enrolled">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="EnrollMaximum"  HeaderText="Seats"      UniqueName="EnrollMaximum">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn HeaderText="Select" ItemStyle-Width="10%" UniqueName="ShowOnPlanner_2">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                                <ItemStyle HorizontalAlign="Center" /> 
                                <ItemTemplate> 
                                    <input id="chkSelect" type="checkbox" onclick="chkCourse_clicked(this,'<%# Eval("SectionNumber") %>');" /> 
                                </ItemTemplate> 
                                <ItemStyle CssClass="RightColumn" /> 
                            </telerik:GridTemplateColumn> 
                        </Columns> 
                    </telerik:GridTableView> 
                </DetailTables> 
                <ItemStyle VerticalAlign="Top" /> 
                <Columns> 
                    <telerik:GridTemplateColumn UniqueName="CourseDescription">  
                        <ItemTemplate> 
                            <asp:Label ID="DepartmentNameLabel" runat="server" 
                                Text='<%# UCase(Eval("DepartmentName") & " " & Eval("CourseNumber") & " - " & Eval("CourseName")) %>' /> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                </Columns> 
            </telerik:GridTableView> 
        </DetailTables> 
        <ItemStyle BackColor="#FFCC66" BorderColor="#444444" BorderStyle="Solid" BorderWidth="1PX" 
            Font-Bold="True" Font-Italic="False" Font-Names="Verdana" Font-Overline="False" 
            Font-Size="8pt" Font-Strikeout="False" Font-Underline="False" ForeColor="#444444" 
            HorizontalAlign="Left" VerticalAlign="Middle" Wrap="False" /> 
        <AlternatingItemStyle BackColor="#FFCC66" BorderColor="#444444" BorderStyle="Solid" 
            BorderWidth="1PX" Font-Bold="True" Font-Italic="False" Font-Names="Verdana" Font-Overline="False" 
            Font-Size="8pt" Font-Strikeout="False" Font-Underline="False" ForeColor="#444444" 
            HorizontalAlign="Left" VerticalAlign="Middle" Wrap="False" /> 
        <PagerStyle Visible="false" Mode="NextPrev" Position="TopAndBottom" /> 
        <ExpandCollapseColumn Visible="True" /> 
    </MasterTableView> 
</telerik:RadGrid> 
 

And here are my datasources:

<asp:ObjectDataSource ID="dsrDepartments" runat="server" SelectMethod="dbSelect" TypeName="WLAC.UilDepartment">  
    <SelectParameters> 
        <asp:Parameter Name="intDepartmentId"   Type="int32"    DefaultValue="0"    /> 
        <asp:Parameter Name="intDivisionId"     Type="int32"    DefaultValue="0"    /> 
        <asp:Parameter Name="intMaxRows"        Type="int32"    DefaultValue="0"    /> 
    </SelectParameters> 
</asp:ObjectDataSource> 
<asp:ObjectDataSource ID="dsrCourses" runat="server" SelectMethod="dbSelect" TypeName="WLAC.UilCourse">  
    <SelectParameters> 
        <asp:Parameter          Name="intCourseId"      Type="int32"    DefaultValue="0"    /> 
        <asp:SessionParameter   Name="intDepartmentId"  Type="int32"    SessionField="DepartmentId" /> 
        <asp:Parameter          Name="intMaxRows"       Type="int32"    DefaultValue="0"    /> 
    </SelectParameters> 
</asp:ObjectDataSource> 
<asp:ObjectDataSource ID="dsrSections" runat="server" SelectMethod="dbSelect" TypeName="WLAC.UilSection">  
    <SelectParameters> 
        <asp:Parameter Name="intCourseId"       Type="int32"    DefaultValue="0"    /> 
        <asp:Parameter Name="intMaxRows"        Type="int32"    DefaultValue="0"    /> 
    </SelectParameters> 
</asp:ObjectDataSource> 
 

TIA,

  Ed

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 21 Jun 2010, 12:23 PM
Hi Ed,

Please refer to the following forum post for more information on the matter:
RadGrid with ObjectDataSource and Hierarchy

Let me know if you need further assistance.

Sincerely yours,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Ed McCarroll
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or