Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I want to bind list to TreeView. But it should work like that:

I work with entity framework. In easiest case I have 2 tables with 2 associations.

Customer
Product

Customer is connected with itself
Customer.CustomerID - Customer.ParentID
and
Product.CustomerID - Customer.CustomerID

Right now I want to populate TreeView and achieve something like this:

Customer1
    SubCustomer1
        Product1
        Product2
    Product3
Customer2
    Product4
Customer3
    SubCustomer2
        Product5
    SubCustomer3
        SubCustomer4
             Product6
        Product7
    Product8

I want to see only Name properties and somehow detect which one is clicked.

Customer Table has 3 navigation properties
Products
CustomerChildren
CustomerParent

Product table has 3 navigation properties but I don't want to use it in TreeView.

In runtime I want to click on some Product, detect that Product is selected (stop if customer is selected) and then make some database modification according to other controls.

Can someone help?
Posted

you should use N-level Database Driven Dynamic Menu concept ,and its position vertically
please go through below link and let me know if any issue

Database Driven Dynamic Menu Control[^]

with EntityFramework[^]
 
Share this answer
 
v3
I wanted use some automatic binding but I create recursive function to populate TreeView with TreeViewItems and then TreeViewItem.Items with another TreeViewItems but this solution isn't efficient. It is very slow solution.
 
Share this answer
 
v2

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