This is a migrated thread and some comments may be shown as answers.

[Solved] Binding IList<> not working in DNN

1 Answer 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Richard Maly
Top achievements
Rank 1
Richard Maly asked on 12 Jan 2010, 10:37 AM
Hiya,
I do not know if DNN is a red herring or not.

I have an IList<CategoryInfo> of items which looks like this
 public class CategoryInfo 
    { 
 
        public int ModuleId{get; set;} 
        public int ItemId{get; set;} 
        public int CreatedByUser{get; set;} 
        public string Content { get; set; } 
        public DateTime CreatedDate{get; set;} 
        public string CategoryDescription{ get; set;} 
        public int? ParentId { get; set; } 
 
    } 

which I am trying to bind to a treeview using the following.

            var objCategories = new CategoryController(); 
             
            RadTreeView1.DataSource = objCategories.GetCategories(ModuleId);  
            RadTreeView1.DataTextField = "CategoryDescription"
            RadTreeView1.DataValueField = "ItemId"
            RadTreeView1.DataFieldParentID = "ParentId"
            RadTreeView1.DataBind(); 

my result set looks like this
ModuleId    itemId      CategoryDescription                                parentId  
----------- ----------- -------------------------------------------------- ----------
381         0                                                              NULL      
381         831         CraftyPatterns                                     0         
381         832         ClassicPatterns                                    0         
381         957         CreativePatterns                                   0         
381         1631        Textures                                           0         
381         1688        Themes                                             0         
381         1689        Animals                                            1688      
381         1700        DELETE TO TRASH                                    1688      
381         1705        Events                                             1688      
381         1738        Floral                                             1688      
381         1748        Gardening                                          1688      
381         1750        Holidays                                           1688      
381         1760        Music                                              1688      
381         1778        Shapes                                             1688      
381         1783        Sports                                             1688      
381         1794        Travel                                             1688      
381         1795        Par Avion                                          1794      
381         1784        Golf                                               1783      
381         1787        Soccer                                             1783      
381         1788        Soccer Kits                                        1787      
381         1789        All Red                                            1788      
381         1790        Blue                                               1788      
381         1791        Green Hoops                                        1788      
381         1792        Red                                                1788      
381         1793        White                                              1788      
381         1785        Golf Mad                                           1784      

but when I run the code it returns a flat tree, I am sure I am missing something but I can not fathom it out.

TIA
Richard

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar Milushev
Telerik team
answered on 14 Jan 2010, 05:44 PM
Hello Richard Maly,

Can you please try setting the TreeView's DataFieldID to the column that should contain the TreeView's ID? I believe it is the 'ItemId' in your case.

Kind regards,
Dimitar Milushev
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.
Tags
TreeView
Asked by
Richard Maly
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Share this question
or