Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
<pre lang="c#">
Hello
I have a Database table for "Products Group" that has a field name "Parent ID". for example if you have "Refrigerator" as you Product ID, it has the "Kitchen Ware" ID as it's Parent ID. How can I have a treeList in DevExpress to have child nodes under it's parent? My database is SQL server.

I have add a treeList in my form that has 2 colomn, then add a class to fetch data from sql database :

C#
public List<LocalProductGroups> GetProductGroups()
       {
           using (ShoppingEntities _ShoppingEntities = new ShoppingEntities())
           {
               return _ShoppingEntities.ProductGroup.Select(s => new LocalProductGroups
               {
                   GroupID=s.GroupID,
                   Name=s.Name,
                   Parent=s.Parent
               }).ToList();
           }

       }
       public partial class LocalProductGroups
       {
           public int GroupID { get; set; }
           public string Name { get; set; }
           public int Parent { get; set; }
           public bool IsRemove { get; set; }
       }


data is shown in treelist but not in parent and child format, I mean all Product Goups are in one level.

Thanks in Advance

What I have tried:

I have tried my code above based on DevExpress documentations, but I have not met my answer.
Posted
Updated 7-Sep-16 21:01pm
v2
Comments
Maciej Los 7-Sep-16 16:16pm    
You have to provide what have you tried. This piece of information is useless.

1 solution

I've found the following:
How to: Implement Hierarchical Data Binding via Child Nodes Selector[^]
Tree Generation Algorithm in the Tree List[^]
Tree List control's features[^]
Display Hierarchical Data - ASP.NET AJAX Tree List Demo | DevExpress[^]

If it won't help, come back here and shortly describe what have you tried to achieve and how. Piece of code you used may be helpful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900