随笔 - 290  文章 - 10  评论 - 85  2

   Treeview 可以绑定支持IHierarchicalDataSource接口的数据

那就让dataTable转成該结构TreeViewDataSource.rar

 

    //调用方法        

    DataTable dt = getCategoriesData();
            InsTreeViewDataSource dataSource = new InsTreeViewDataSource
                ("parentcode", "categorycode", "categoryname", dt);

            TreeView1.DataSource = dataSource;
            TreeNodeBinding bind = new TreeNodeBinding();
            bind.TextField = "categoryname";
            bind.ValueField = "categorycode";
            TreeView1.DataBindings.Add(bind);
            TreeView1.DataBind();

posted on 2010-02-03 16:43  Gu  阅读(...)  评论(...编辑  收藏