TreeView Bind Error:"This constraint cannot be enabled as not all values have corresponding parent values."

2 posts, 0 answers
  1. shady
    shady avatar
    1 posts
    Member since:
    Nov 2015

    Posted 16 Nov 2015 Link to this post

    Hi everyone.
    I've a problem with my TreeView controls. the problem is;

    When I try to bind data from DB to RadTreeView, it gives this error : "This constraint cannot be enabled as not all values have corresponding parent values."

    Default.aspx

    <body>
        <form id="form1" runat="server">
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MedsConnectionString %>" SelectCommand="sp_MAIN_ACC_TREE" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:Parameter DefaultValue="1" Name="ACC_id_A" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <div>

            <telerik:RadTreeView ID="RadTreeView1" Runat="server" DataFieldID="ACC_ID_A" DataFieldParentID="ACC_PARENT_A" DataSourceID="SqlDataSource1" DataTextField="ACC_NAME_A" DataValueField="ACC_ID_A" Height="131px" OnNodeClick="RadTreeView1_NodeClick">
            </telerik:RadTreeView>

        </div>
        </form>
    </body>

     DataTable : 

    ACC_ID_A           ACC_NAME_A           ACC_PARENT_A

     

     1                            Accounting tree                  NULL

     2                            essential                               1

     3                            Cars                                      2

    4                              Ambulance                          3

     

    stored procedure : 

    ALTER PROCEDURE [dbo].[sp_MAIN_ACC_TREE]
    @ACC_id_A as int
    AS
    BEGIN
    with subtree2(ACC_ID_A , ACC_NAME_A , ACC_PARENT_A)
    as
    (
    select * from MAIN_ACC_A where ACC_PARENT_A = @ACC_id_A
    union all
    select e.ACC_ID_A, e.ACC_NAME_A ,e.ACC_PARENT_A from MAIN_ACC_A
    as e inner join subtree2 on subtree2.ACC_ID_A=e.ACC_PARENT_A
    )
    select * from subtree2
    order by ACC_PARENT_A
    END

     

    I need solve this problem necessary

    thanks

  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 19 Nov 2015 Link to this post

    Hello Shady,

    The data structure and configuration of the RadTreeView is correct. The reason for the experienced issue is probably related with the stored procedure that you are using. Please make sure that the data is served correctly from the stored procedure that you use.

    Regards,
    Nencho
    Telerik
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top