Datalist inside RadGrid...?

5 posts, 0 answers
  1. YMA
    YMA avatar
    5 posts
    Member since:
    Sep 2006

    Posted 28 Aug 2012 Link to this post

    I wonder if someone could help me solve this issue:

    I need to have a Datalist (for layout purposes etc.) inside a RadGrid in a Parent/Child relationship.


    For some reason the parent/child link does not quite work for me. In the Northwind database when I click on say OrderID 10248 -it also populates the order details of OrderID 10248 to all the other OrderID's (i.e. 10249, 10250 etc.). What I am doing wrong...?

    Thanks in advance!


    The sample code is included below:
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                <asp:ScriptReference Assembly="Telerik.Web.UI"
            <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0"
                DataSourceID="SqlDataSource1" GridLines="None">
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID"
                    <telerik:GridRelationFields DetailKeyField="OrderID"
                        MasterKeyField="OrderID" />
            <asp:DataList ID="DataList1" runat="server" DataKeyField="OrderID"
                    <asp:Label ID="OrderIDLabel" runat="server" Text='<%# Eval("OrderID") %>' />
                    <br />
                    <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
                    <br />
                    <asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' />
                    <br />
                    <asp:Label ID="QuantityLabel" runat="server" Text='<%# Eval("Quantity") %>' />
                    <br />
                    <asp:Label ID="DiscountLabel" runat="server" Text='<%# Eval("Discount") %>' />
                    <br />
    <br />
        <NestedViewSettings DataSourceID="SqlDataSource2">
                <telerik:GridRelationFields DetailKeyField="OrderID"
                    MasterKeyField="OrderID" />
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
            <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
                FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
                ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
            <telerik:GridBoundColumn DataField="CustomerID"
                FilterControlAltText="Filter CustomerID column" HeaderText="CustomerID"
                SortExpression="CustomerID" UniqueName="CustomerID">
            <telerik:GridBoundColumn DataField="EmployeeID" DataType="System.Int32"
                FilterControlAltText="Filter EmployeeID column" HeaderText="EmployeeID"
                SortExpression="EmployeeID" UniqueName="EmployeeID">
            <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime"
                FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
                SortExpression="OrderDate" UniqueName="OrderDate">
            <telerik:GridBoundColumn DataField="RequiredDate" DataType="System.DateTime"
                FilterControlAltText="Filter RequiredDate column" HeaderText="RequiredDate"
                SortExpression="RequiredDate" UniqueName="RequiredDate">
            <telerik:GridBoundColumn DataField="ShippedDate" DataType="System.DateTime"
                FilterControlAltText="Filter ShippedDate column" HeaderText="ShippedDate"
                SortExpression="ShippedDate" UniqueName="ShippedDate">
            <telerik:GridBoundColumn DataField="ShipVia" DataType="System.Int32"
                FilterControlAltText="Filter ShipVia column" HeaderText="ShipVia"
                SortExpression="ShipVia" UniqueName="ShipVia">
            <telerik:GridBoundColumn DataField="Freight" DataType="System.Decimal"
                FilterControlAltText="Filter Freight column" HeaderText="Freight"
                SortExpression="Freight" UniqueName="Freight">
            <telerik:GridBoundColumn DataField="ShipName"
                FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
                SortExpression="ShipName" UniqueName="ShipName">
            <telerik:GridBoundColumn DataField="ShipAddress"
                FilterControlAltText="Filter ShipAddress column" HeaderText="ShipAddress"
                SortExpression="ShipAddress" UniqueName="ShipAddress">
            <telerik:GridBoundColumn DataField="ShipCity"
                FilterControlAltText="Filter ShipCity column" HeaderText="ShipCity"
                SortExpression="ShipCity" UniqueName="ShipCity">
            <telerik:GridBoundColumn DataField="ShipRegion"
                FilterControlAltText="Filter ShipRegion column" HeaderText="ShipRegion"
                SortExpression="ShipRegion" UniqueName="ShipRegion">
            <telerik:GridBoundColumn DataField="ShipPostalCode"
                FilterControlAltText="Filter ShipPostalCode column" HeaderText="ShipPostalCode"
                SortExpression="ShipPostalCode" UniqueName="ShipPostalCode">
            <telerik:GridBoundColumn DataField="ShipCountry"
                FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
                SortExpression="ShipCountry" UniqueName="ShipCountry">
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    <FilterMenu EnableImageSprites="False"></FilterMenu>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                SelectCommand="SELECT OrderID, ProductID, UnitPrice, Quantity, Discount FROM [Order Details] WHERE (OrderID = @OrderID)">
                    <asp:Parameter Name="OrderID" Type="Int32" />

  2. Radoslav
    Radoslav avatar
    1566 posts

    Posted 03 Sep 2012 Link to this post

    Hello YMA,

    I am sending you the modified version of your code please check it out and let me know if it helps you. Looking forward for your reply.

    All the best,
    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.
  3. YMA
    YMA avatar
    5 posts
    Member since:
    Sep 2006

    Posted 04 Sep 2012 Link to this post

    Hi Radoslav,

    Just tried it and it works perfectly thanks!! I spent about three weeks trying to figure out what I was doing wrong in the code. The trick seems to be to (1) have the detail datasource control inside the <NestedViewTemplate>, (2) store the OrderID values at order level in a (hidden) data-bound label, (3) remove the <NestedViewSettings> tag.

    Again thanks -much appreciated!

  4. Bethany
    Bethany avatar
    14 posts
    Member since:
    Mar 2015

    Posted 17 Aug 2015 Link to this post


     The example you sent doesn't seem to work anymore. Can you post the specific code related to finding the DataList control programmatically in I just need that one piece and I cannot find it anywhere.

  5. Eyup
    Eyup avatar
    3937 posts

    Posted 19 Aug 2015 Link to this post

    Hello Bethany,

    I've already provided a runnable web site to demonstrate how you can achieve this requirement in your other forum thread:

    I can see that you have also opened a formal support ticket with ID: 962460, which is handled by Viktor. I suggest that we continue this conversation only on one of these threads.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top