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

Nested Grid (based on demo code) not working

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Iris
Top achievements
Rank 1
Iris asked on 23 Jul 2012, 04:54 AM
I tried to recreate this demo: http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx

I copied the code given at the bottom of the page and made a few changes. I also changed the panel visibility to true since the panel and the items in it (the grid, tabs, panel background image) will not be displayed if the visibility is set to false. I don't know why you set the panel's visibility to false in the code given. Care to enlighten me on this?

However that's not the reason why I create this thread. When I tried to debug, I get this error message:

Could not find control 'Label1' in ControlParameter 'ParentID'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find control 'Label1' in ControlParameter 'ParentID'.


I'm this close to tearing my hair out trying to debug this. Can you tell me what went wrong?

Here's my code:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MiniApp5b._Default" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
 
<asp:SqlDataSource ID="edata3" runat="server" ConnectionString="<%$ ConnectionStrings:GreenDataConnectionString %>" SelectCommand="SELECT * FROM [Category5Parent]">
</asp:SqlDataSource>
 
<asp:SqlDataSource ID="edata5" runat="server"
        ConnectionString="<%$ ConnectionStrings:GreenDataConnectionString %>"
        SelectCommand="
            SELECT *
            FROM Category5Child
                INNER JOIN Category5Parent
                ON Category5Child.ParentID = Category5Parent.ParentID
            WHERE ParentID = @ParentID
            ">
    <SelectParameters>
        <asp:ControlParameter ControlID="Label1" PropertyName="Text" Type="Int32" Name="ParentID" />
    </SelectParameters>
</asp:SqlDataSource>
 
    <telerik:RadGrid ID="RadGrid4" runat="server" CellSpacing="0" DataSourceID="edata3" GridLines="None">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="ParentID"  DataSourceID="edata3">
            <NestedViewTemplate>
                <asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap1" Visible="true">
                    <telerik:RadTabStrip runat="server" ID="TabStrip1" MultiPageID="Multipage1" SelectedIndex="0">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Sales" PageViewID="PageView1">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Contact Information" PageViewID="PageView2">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Statistics Chart" PageViewID="PageView3">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
 
                    <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="PageView1">
                            <asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("ParentID") %>' Visible="false" runat="server" />
                            <telerik:RadGrid runat="server" ID="GridIntab" DataSourceID="edata5" ShowFooter="true" AllowSorting="true" EnableLinqExpressions="false">
                                 
                                <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true" DataKeyNames="ChildID" PageSize="7" HierarchyLoadMode="ServerOnDemand">
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="ChildID" DataType="System.Int32"
                                            FilterControlAltText="Filter ChildID column" HeaderText="ChildID"
                                            ReadOnly="True" SortExpression="ChildID" UniqueName="ChildID">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ChildName"
                                            FilterControlAltText="Filter ChildName column" HeaderText="ChildName"
                                            SortExpression="ChildName" UniqueName="ChildName">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ParentID" DataType="System.Int32"
                                            FilterControlAltText="Filter ParentID column" HeaderText="ParentID"
                                            SortExpression="ParentID" UniqueName="ParentID">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
 
                        <telerik:RadPageView runat="server" ID="PageView2" Width="460px">
                        <%--
                        TO DO
                        --%>
                        </telerik:RadPageView>
 
                        <telerik:RadPageView runat="server" ID="PageView3">
                        <%--
                        TO DO
                        --%>
                        </telerik:RadPageView>
 
                    </telerik:RadMultiPage>
                </asp:Panel>
            </NestedViewTemplate>
 
            <CommandItemSettings ExportToPdfText="Export to PDF">
            </CommandItemSettings>
 
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
 
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
 
            <Columns>
                <telerik:GridBoundColumn DataField="ParentID" DataType="System.Int32"
                    FilterControlAltText="Filter ParentID column" HeaderText="ParentID"
                    ReadOnly="True" SortExpression="ParentID" UniqueName="ParentID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ParentName"
                    FilterControlAltText="Filter ParentName column" HeaderText="ParentName"
                    SortExpression="ParentName" UniqueName="ParentName">
                </telerik:GridBoundColumn>
            </Columns>
 
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
</telerik:RadGrid>
</asp:Content>

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 23 Jul 2012, 05:07 PM
Hi Iris,

Note that the SQL dataSource for the nested Grids and the mentioned label should be added into the NestedViewTemplate in order to have the application works correctly.

Give this suggestion a try and let me know if it works for you.

All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Iris
Top achievements
Rank 1
answered on 30 Jul 2012, 04:11 AM
Thanks for the info. Now I can get it to work.

I'm just wondering, is it possible to put the dataSource outside the NestedViewTemplate? I've seen several examples (not for NestedViewTemplate) where it is possible to place the dataSource outside and changing the ControlID's path in ControlParameter tag. I've tried changing the path but none works.
Tags
Grid
Asked by
Iris
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Iris
Top achievements
Rank 1
Share this question
or