Treeviw for the father and son ID table

xiaoxiao2021-03-17  183

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}}}}}}}}

转载请注明原文地址:https://www.9cbs.com/read-129500.html

New Post(0)