Geeks With Blogs
AzamSharp Some day I will know everything. I hope that day never comes.

I have recently published an article on GridViewGuy on how to populate the TreeView control using the database. The article demonstrate the solution using entity classes. Here is a small code snippet from the article.


// This method is used to populate the TreeView Control 
    
private void PopulateTreeViewControl(List<Category> categoryList)
    {
        TreeNode parentNode = 
null

        
foreach (Category category in categoryList)
        {
            parentNode = 
new TreeNode(category.CategoryName,
            category.CategoryID.ToString());
            
            
foreach (Product product in category.ProductList)
            {
                TreeNode childNode = 
new TreeNode(product.ProductName,
                product.ProductID.ToString());
             
                parentNode.ChildNodes.Add(childNode); 
            }

                    
            parentNode.Collapse(); 
            
// Show all checkboxes 
            
tvCategories.ShowCheckBoxes = TreeNodeTypes.All; 
            tvCategories.Nodes.Add(parentNode); 
        }
    }

For the complete article please visit the following link:

Populating TreeView Using Database

powered by IMHO 1.3

Posted on Wednesday, June 28, 2006 8:51 PM | Back to top


Comments on this post: Populating TreeView Control With Database

# re: Populating TreeView Control With Database
Requesting Gravatar...
<div style="display:none"/>
Left by sad on Jun 25, 2007 1:59 PM

Your comment:
 (will show your gravatar)


Copyright © Mohammad Azam | Powered by: GeeksWithBlogs.net