rad menu datasource databind doesn't work - bug

3 posts, 0 answers
  1. Vjeran
    Vjeran avatar
    24 posts
    Member since:
    Oct 2005

    Posted 20 Oct 2009 Link to this post

    When i check the list in debug, it is filled correctly and then it is

    Here is the code:
    aspx:
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <div>
        <telerik:RadMenu runat="server" ID="CategoriesMenu" Skin="Black"
        DataTextField="Title" DataFieldID="Id"
                DataSourceID="objectDS" DataFieldParentID="ParentId"
                DataNavigateUrlField="Id" DataValueField="Id" AppendDataBoundItems="True">
        </telerik:RadMenu>
        <asp:GridView runat="server" ID="TestGrid"></asp:GridView>
        </div>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server"
            ContextTypeName="IpitchitWebsiteModel.IpitchitWebsiteModelDataContext"
            Select="new (Id, ParentID, Title)" TableName="Categories">
        </asp:LinqDataSource>
        <asp:ObjectDataSource runat="server" ID="objectDS" SelectMethod="GetTreeByParent"
        TypeName="IpitchitWebsiteModel.DataRepository.CategoryRepositoy">
        <SelectParameters>
            <asp:Parameter Name="id" Type="Int32" DefaultValue="10" />
            <asp:Parameter Name="visibility" Type="Int32" DefaultValue="0" />
            <asp:Parameter Name="showRootCategory" Type="Boolean" DefaultValue="false" />
        </SelectParameters>
        </asp:ObjectDataSource>
    cs:
            [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
            public List<Categories_GetTreeByParentResult> GetTreeByParent(int? id, int visibility, bool showRootCategory)
            {
                return db.Categories_GetTreeByParent(id, visibility, showRootCategory).ToList();
            }

    from dbml:
        public partial class Categories_GetTreeByParentResult 
        { 
             
            private System.Nullable<int> _Id; 
             
            private System.Nullable<int> _ParentId; 
             
            private string _Title; 
             
            private string _Description; 
             
            private System.Nullable<int> _Ordering; 
             
            private System.Nullable<System.DateTime> _CreatedDate; 
             
            private string _CreatedBy; 
             
            private System.Nullable<System.DateTime> _ModifiedDate; 
             
            private string _ModifiedBy; 
             
            private System.Nullable<bool> _IsSearchable; 
             
            private System.Nullable<byte> _VisiblityIndex; 
             
            private System.Nullable<int> _RecursionLevel; 
             
            private string _Path; 
             
            public Categories_GetTreeByParentResult() 
            { 
            } 
             
            [Column(Storage="_Id"DbType="Int")] 
            public System.Nullable<int> Id 
            { 
                get 
                { 
                    return this._Id; 
                } 
                set 
                { 
                    if ((this._Id != value)) 
                    { 
                        this._Id = value
                    } 
                } 
            } 
             
            [Column(Storage="_ParentId"DbType="Int")] 
            public System.Nullable<int> ParentId 
            { 
                get 
                { 
                    return this._ParentId; 
                } 
                set 
                { 
                    if ((this._ParentId != value)) 
                    { 
                        this._ParentId = value
                    } 
                } 
            } 
             
            [Column(Storage="_Title"DbType="NVarChar(250)")] 
            public string Title 
            { 
                get 
                { 
                    return this._Title; 
                } 
                set 
                { 
                    if ((this._Title != value)) 
                    { 
                        this._Title = value
                    } 
                } 
            } 
             
            [Column(Storage="_Description"DbType="NVarChar(300)")] 
            public string Description 
            { 
                get 
                { 
                    return this._Description; 
                } 
                set 
                { 
                    if ((this._Description != value)) 
                    { 
                        this._Description = value
                    } 
                } 
            } 
             
            [Column(Storage="_Ordering"DbType="Int")] 
            public System.Nullable<int> Ordering 
            { 
                get 
                { 
                    return this._Ordering; 
                } 
                set 
                { 
                    if ((this._Ordering != value)) 
                    { 
                        this._Ordering = value
                    } 
                } 
            } 
             
            [Column(Storage="_CreatedDate"DbType="SmallDateTime")] 
            public System.Nullable<System.DateTime> CreatedDate 
            { 
                get 
                { 
                    return this._CreatedDate; 
                } 
                set 
                { 
                    if ((this._CreatedDate != value)) 
                    { 
                        this._CreatedDate = value
                    } 
                } 
            } 
             
            [Column(Storage="_CreatedBy"DbType="NVarChar(50)")] 
            public string CreatedBy 
            { 
                get 
                { 
                    return this._CreatedBy; 
                } 
                set 
                { 
                    if ((this._CreatedBy != value)) 
                    { 
                        this._CreatedBy = value
                    } 
                } 
            } 
             
            [Column(Storage="_ModifiedDate"DbType="SmallDateTime")] 
            public System.Nullable<System.DateTime> ModifiedDate 
            { 
                get 
                { 
                    return this._ModifiedDate; 
                } 
                set 
                { 
                    if ((this._ModifiedDate != value)) 
                    { 
                        this._ModifiedDate = value
                    } 
                } 
            } 
             
            [Column(Storage="_ModifiedBy"DbType="NVarChar(50)")] 
            public string ModifiedBy 
            { 
                get 
                { 
                    return this._ModifiedBy; 
                } 
                set 
                { 
                    if ((this._ModifiedBy != value)) 
                    { 
                        this._ModifiedBy = value
                    } 
                } 
            } 
             
            [Column(Storage="_IsSearchable"DbType="Bit")] 
            public System.Nullable<bool> IsSearchable 
            { 
                get 
                { 
                    return this._IsSearchable; 
                } 
                set 
                { 
                    if ((this._IsSearchable != value)) 
                    { 
                        this._IsSearchable = value
                    } 
                } 
            } 
             
            [Column(Storage="_VisiblityIndex"DbType="TinyInt")] 
            public System.Nullable<byte> VisiblityIndex 
            { 
                get 
                { 
                    return this._VisiblityIndex; 
                } 
                set 
                { 
                    if ((this._VisiblityIndex != value)) 
                    { 
                        this._VisiblityIndex = value
                    } 
                } 
            } 
             
            [Column(Storage="_RecursionLevel"DbType="Int")] 
            public System.Nullable<int> RecursionLevel 
            { 
                get 
                { 
                    return this._RecursionLevel; 
                } 
                set 
                { 
                    if ((this._RecursionLevel != value)) 
                    { 
                        this._RecursionLevel = value
                    } 
                } 
            } 
             
            [Column(Storage="_Path"DbType="VarChar(2000)")] 
            public string Path 
            { 
                get 
                { 
                    return this._Path; 
                } 
                set 
                { 
                    if ((this._Path != value)) 
                    { 
                        this._Path = value
                    } 
                } 
            } 
        } 


    So when i remove parentid parameter DataFieldParentID menu control will work. Otherwise not. This looks to me as bug.


  2. Vjeran
    Vjeran avatar
    24 posts
    Member since:
    Oct 2005

    Posted 21 Oct 2009 Link to this post

    I found the bug - if this is a bug. Here is the case. I use, lets say standard categories table- Id, ParentId. I wanted to display subcategories in menu, but those subcategories have real root category. Therefore they will not have ParentId null but some number. Menu will work fine, when i place null for categories which should behave as root.




  3. Yana
    Admin
    Yana avatar
    4910 posts

    Posted 21 Oct 2009 Link to this post

    Hi Vjeran,

    This is the expected behavior of RadMenu hierarchical databinding mechanism - when ParentID is null, the item is root item, otherwise ParentID is set to the id of its parent item. You can find more information about this here.

    Greetings,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top