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."


        <form id="form1" runat="server">
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MedsConnectionString %>" SelectCommand="sp_MAIN_ACC_TREE" SelectCommandType="StoredProcedure">
                    <asp:Parameter DefaultValue="1" Name="ACC_id_A" Type="Int32" />
            <br />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <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" />
        <script type="text/javascript">
            //Put your JavaScript code here.
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

            <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">


     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 : 

    @ACC_id_A as int
    with subtree2(ACC_ID_A , ACC_NAME_A , ACC_PARENT_A)
    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


    I need solve this problem necessary


  2. Nencho
    Nencho avatar
    1446 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.

    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. DevCraft R3 2016 release webinar banner
Back to Top