private void bindTree()
 {
      DataTable dt = DB.FillDataTable_Pro("select item_clsname,item_clsno from bi_t_item_cls where item_flag=0");
      this.ASPxTreeView1.Nodes.Clear();        
      this..Nodes.Add("所有类别");
        DevExpress.Web.ASPxTreeView.TreeViewNode node = new DevExpress.Web.ASPxTreeView.TreeViewNode();        
        DevExpress.Web.ASPxTreeView.TreeViewNode node1 = ASPxTreeView1.Nodes[0];       
        DevExpress.Web.ASPxTreeView.TreeViewNode node2 = this.ASPxTreeView1.Nodes[0];    
  if (dt.Rows.Count != 0)        
     {          
       foreach (DataRow var in dt.Rows)           
       {                 
        if (var[1].ToString().Trim().Length == 2 || var[1].ToString().Trim().Length == 3)         
        {                    
             this.ASPxTreeView1.Nodes[0].Nodes.Add(var[0].ToString().Trim(), var[1].ToString().Trim());                   
              node = this.ASPxTreeView1.Nodes[0].Nodes[this.ASPxTreeView1.Nodes[0].Nodes.Count - 1];  
          }               
           else if (var[1].ToString().Trim().Length == 4 || var[1].ToString().Trim().Length == 5)                
          {                   
                node.Nodes.Add(var[0].ToString().Trim(), var[1].ToString().Trim());                      node1 = node.Nodes[node.Nodes.Count - 1];             
           }                
            else if (var[1].ToString().Trim().Length == 6 || var[1].ToString().Trim().Length == 7)                
           {                    
               node1.Nodes.Add(var[0].ToString().Trim(), var[1].ToString().Trim());                    node2 = node1.Nodes[node1.Nodes.Count - 1];               
           }                
           else                
           {                   
                 node2.Nodes.Add(var[0].ToString().Trim(), var[1].ToString().Trim());                
            }           
        }      
     }   
   }

ASPxTreeView1的数据邦定_职场