Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have 2 tables customer and user in customer cust_no is unique for that Customer i can add any number of users for that particular Customer No So, Now i have to show this in a TreeView like Customer No should be the Parent Node and the User No should be the Child Node (Like if we have 10 Customers and each Customer have more than 1 User if we click on Cust No we have to get the User No as Child Nodes)

I have tried a bit i got the Cust No but not able to get the User No as the Child Nodes
C#
void FillTreeView()
        {
            client.CustNoCompleted += new System.EventHandler<CustNoCompletedEventArgs>(client_CustNoCompleted);
            client.CustNoAsync();

        }

        void client_CustNoCompleted(object sender, CustNoCompletedEventArgs e)
        {
            TreeViewItem tvitem = new TreeViewItem();
            tvitem.Header = "Customer";

            List<Cust> cust = e.Result;
            var list = from o in cust
                       select o.Customer_No;

            custtreeview.ItemsSource = list;

            //treeview.ItemsSource = list;

        }
Posted
Updated 13-Feb-11 23:55pm
v3
Comments
#realJSOP 14-Feb-11 6:08am    
Your question has nothing to do with WCF.

 
Share this answer
 
You need to use binding as demonstrated below.

XML
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Margin="5,0" />
</StackPanel>
</control:HierarchicalDataTemplate>
</control:TreeView.ItemTemplate>


Also, see here[^].
 
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