this constraint cannot be enabled as not all values have corresponding parent values

2 posts, 0 answers
  1. Rizwan Ansari
    Rizwan Ansari avatar
    26 posts
    Member since:
    Nov 2009

    Posted 28 Oct 2014 Link to this post

    Dear Support,

    I am getting above error when radmenu is getting its datasource dynamically. please check the below code.

    Create PROCEDURE [dbo].[HGetSubMenu]
    (
    @categoryid int
    )
    AS
    begin
    DECLARE @level int
      
        /* Creating temporary table for tree storage*/
        CREATE TABLE #temp_tree
        (
            level int,
            id int NOT NULL PRIMARY KEY,
            ptr int,
            f1 char(20)
        )
      
        INSERT #temp_tree (level, id, ptr, f1)
        SELECT 0, categoryid, parentid, categoryname FROM HCategroyNew WHERE categoryid = @categoryid
        SELECT @level = 0
      
        WHILE 1 = 1
        BEGIN
            INSERT #temp_tree (level, id, ptr, f1)
            SELECT
                @level + 1, HCategroyNew.categoryid, HCategroyNew.parentid, HCategroyNew.categoryname  
            FROM
                HCategroyNew, #temp_tree tt
            WHERE
                    HCategroyNew.parentid = tt.id
                AND tt.level = @level
      
            IF @@rowcount = 0 BREAK
             
            SELECT @level = @level + 1
        END
      
        SELECT id, ptr, f1,level
        FROM #temp_tree
        DROP TABLE #temp_Tree
    end

    Dataset Table Structure
    id  ptr f1                     level
    3   1   Bedrooms                0
    13  3   Classical               1
    14  3   Modern                  1
    15  3   Contemporary            1
    16  3   Transitional            1
    17  3   Arte Deco               1

    Radmenu Binding.
    RadMenu1.DataSource = ds.Tables[0];
                 
                RadMenu1.Flow = ItemFlow.Horizontal;
                RadMenu1.DataTextField = "f1";
                RadMenu1.DataFieldID = "ptr";
                RadMenu1.DataValueField = "id";
                RadMenu1.DataFieldParentID = "level";
                RadMenu1.DataBind();

    Please help me urgent.

    Thanks
    Rizwan
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 30 Oct 2014 Link to this post

    Hi Rizwan,

    The tree expects that you will have at least one root item. For example:
    id  ptr f1                     level
    3   NULL   Bedrooms                0
    13  3   Classical               1
    14  3   Modern                  1
    15  3   Contemporary            1
    16  3   Transitional            1
    17  3   Arte Deco               1

    At the moment the first item has parent item with ID #1 and this parent is not among the returned rows. 

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top