table:
PERID parent ID, ID primary key (sub ID)
___________________________________
Protected Void Page_Load (Object Sender, Eventargs E) {
using (SqlConnection Conn = new SqlConnection (logicClass.strConn ())) {Conn.Open (); string strsql = "select preid, id, name, keynum, ctime, orderid from doctree"; SqlDataAdapter sa = new SqlDataAdapter (strsql, CONN); DataSet DS = New Dataset (); Sa.Fill (DS); this.ViewState ["DS"] = DS; conn.dispose (); conn.close ();} // end using}
// Removable Add Tree Node Public Void AddTree (INT ParentID, Treenode Pnode) {DataSet DS = (Dataset) this.viewState ["DS"]; dataview DVTree = New DataView (DS.Tables [0]); // Filter ParentID gets all current child dvtree.rowfilter = "[preId] =" ParentID; DVTree.Sort = "ORDERID";
Foreach (DATAROWVIEW ROW IN DVTREE) {Treenode Node = New Treenode (); if (PNode == NULL) {// Add root node node.text = row ["name"]. Tostring (); treec1.nodes.add ( Node.expanded = true; addtree (rot32.parse (row ["ID"]. TOSTRING ()), NODE); // Regeneration again} Else {// Add current node child node.text = row ["name"]. TOSTRING (); // pnode.nodes.add (node); pnode.childnodes.add (node); node.expanded = true; addtree (int32.parse). TOSTRING ()), Node); // Recute again}}}}}}}}