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

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