This constraint cannot be enabled as not all values have corresponding parent values.

5 posts, 0 answers
  1. jo
    jo avatar
    27 posts
    Member since:
    Jul 2008

    Posted 15 Sep 2009 Link to this post

    This is my data on datasource-

    COMPANYID CATEGORYID COMPANYNAME CATEGORYNAME
    687d6bf7 103b9297 a123 abc
    687d6bf7 6903d527 a123 xyz

    This is my code-

    <

     

    telerik:RadTreeView ID="RadTreeView1" runat="server" DataSourceID="ObjectDataSourceCompany"

     

     

    DataTextField="COMPANYNAME" DataFieldID="CATEGORYID" DataFieldParentID="COMPANYID"

     

     

    DataValueField="CATEGORYID">

     

     

    </telerik:RadTreeView>

    This is the Error-

     

    This constraint cannot be enabled as not all values have corresponding parent values.

    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.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.

    Did I miss anything...How do i fix this??

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 16 Sep 2009 Link to this post

    Hello Jo,

    The ParentID of the root items should be null. If for some reason the data source comes without null values for the ParentID column, the solution is to create a query that returns the expected value (null). Check out the code below which shows how to convert ParentID= 0 to ParentID=null
    SELECT ID, Text, IF(ParentID = 0, NULL, ParentID) FROM table

    You may also go throught he following links which refers to the above mentioned:
    Treeview Problem

    -Princy.
  3. JohnRah
    JohnRah avatar
    1 posts
    Member since:
    Aug 2011

    Posted 11 Mar 2015 Link to this post

    Or you can use:

    SELECT
        ID, Text,
        CASE WHEN ParentID=0
            THEN NULL
             ELSE ParentID
        FROM table
  4. Sachita
    Sachita avatar
    2 posts
    Member since:
    Oct 2020

    Posted 11 Jan Link to this post

      private static void CreateDataRelations(ref DataSet ds, bool createConstraints)
            {

                DataRelation dataRelation = new DataRelation("PublicationTypeChildren",
                    ds.Tables[0].Columns[(int)PublicationTypeColumns.Guid],
                    ds.Tables[1].Columns[(int)PublicationTypeChildrenColumns.ParentGuid],
                    createConstraints);
                ds.Relations.Add(dataRelation);
                
            }

    As I have tried Solutions of Many Posts but didnot get any Luck,Can you please help.

  5. Peter Milchev
    Admin
    Peter Milchev avatar
    898 posts

    Posted 14 Jan Link to this post

    Hello Sachita,

    As the error message says, the data has entries that have a non-existent parent node. To debug that, I would recommend to:

    1) Get all ParentIDs of all entries

    2) Check if each of the ParentIDs have a corresponding item with ID equal to the ParentID

    Once you do that, you should find which entries have non-existent parents and fix them.

    Regards,
    Peter Milchev
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top