Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Menu > This constraint cannot be enabled as not all values have corresponding parent values.
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

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

Feed from this thread
  • Posted on Oct 8, 2006 (permalink)

    Hi there,

    Is there any way to make the menu to exclude all item which do not have parentID automatically in order to prevent the following error to occur? 

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

    We are using dataset to populate the menu. Since our data has some record which do not have parentID, the error occurred. It is a live database and we do not wish to remove the data manually. Thanks!

  • Rumen Rumen admin's avatar

    Posted on Oct 9, 2006 (permalink)

    Hello,

    Basically, you can map different  / non-existing ParentID columns to "null" values (the format that r.a.d.menu expects) by changing your SQL syntax:

    SELECT ID, Text, IF(ParentID = 0, NULL, ParentID)
    FROM
    tblData

    The following forum thread might provide useful details for your scenario:
    http://www.telerik.com/community/forums/thread/b311D-ebeed.aspx



    Best wishes,
    Rumen Stankov (MCSD.NET)
    the telerik team

  • scubasteveb avatar

    Posted on May 11, 2010 (permalink)

    I have searched the forum for this issue and noticed in the RadMenu and RadTreeView forums, this issue occurred and it was either suggested to use a sql statement to change values of 0 (for parentid) to NULL which is my case or Telerik was talking about adding a property to these controls to specify what your root value is.

    I see this was never implemented and wish it was. I noticed a Telerik employee suggesting using a property called 'DataFieldRootValue'  in which you could specify 0 as your root items which is my case, so it ignores the constraint.

    Please implement this feature in RadMenu and RadTreeView

    Thanks

  • Yana Yana admin's avatar

    Posted on May 12, 2010 (permalink)

    Hi Steve,

    Thank you for your suggestion. Currently we don't have plans to implement such property, but your request will be logged and considered.

    Greetings,
    Yana
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.

  • scubasteveb avatar

    Posted on May 12, 2010 (permalink)

    Do you have any suggestions/workarounds then if I am using 0 as a root level items versus NULL and I can't change the data in the database.  Could I fill a DataSet maybe and update the column?

  • Yana Yana admin's avatar

    Posted on May 17, 2010 (permalink)

    Hi scubasteveb,

    You can replace "0" values in the sql query like this:

    string sql = @"SELECT ID, Text,
                   CASE WHEN ParentID = 0
                       THEN NULL
                       ELSE ParentID
                   END AS Parent
                   FROM testTable";
     
    SqlDataAdapter adapter = new SqlDataAdapter(sql,
        ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
    DataTable data = new DataTable();
    adapter.Fill(data);
     
    RadMenu1.DataSource = data;
    RadMenu1.DataFieldID = "ID";
    RadMenu1.DataFieldParentID = "Parent";
    RadMenu1.DataTextField = "Text";
    RadMenu1.DataBind();


    Greetings,
    Yana
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.

  • scubasteveb avatar

    Posted on May 18, 2010 (permalink)

    Thanks for the help

  • Krishna Chaudhary avatar

    Posted on May 20, 2010 (permalink)

    This can be done by setting

     datasetobject.EnforceConstraints = false;

  • ying avatar

    Posted on Jun 13, 2011 (permalink)

    I do the checkng below
    string sql = @"SELECT ID, Text,
                   CASE WHEN ParentID = 0
                       THEN NULL
                       ELSE ParentID
                   END AS Parent
                   FROM testTable";

    when the parnetID = 0 , then null, but i still get the same error
    "

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

    "
    can tell me how to solve it

  • Kate Kate admin's avatar

    Posted on Jun 16, 2011 (permalink)

    Hi ying,

    Please take a look at the following forum thread. As a side note I noticed that in the product field it is indicated that you use our ASP.NET classic controls, however, we do not longer provide support for the classic controls as described in the Telerik's Support Lifecycle Policy here.  

    Greetings,
    Kate
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Menu > This constraint cannot be enabled as not all values have corresponding parent values.