1. Recursive function
' Recursive traversal self-built directory tree =============================================================================
private void Showdir (String szml,string sindex)
{
System.Data.SqlClient.SqlConnection sqlcon=new System.Data.SqlClient.SqlConnection (connectionString);
String sqlstr= "select * from mltable where mlzml=n '" + szml + "'";
System.Data.SqlClient.SqlDataAdapter sqlada=new System.Data.SqlClient.SqlDataAdapter (Sqlstr,sqlcon);
System.Data.DataTable dt=new DataTable ();
Sqlada.fill (Dt);
Microsoft.Web.UI.WebControls.TreeNode Node1;
String sIndex0;
String SIndex2;
int Theid;
int sindex1=0;//The last value of the record tree
foreach (System.Data.DataRow dtdatarow in Dt.rows)
{
Theid=convert.toint32 (dtdatarow["Mlid"]);
Node1=new Microsoft.Web.UI.WebControls.TreeNode ();
node1.text=dtdatarow["MLMC"]. ToString ();
Node1.imageurl= "Images/trees/folder.gif";
Node1.expandedimageurl= "Images/trees/folderopen.gif";
Node1.expanded=false;
Node1.navigateurl= "admin_tree_show.aspx?theid=" + Theid + "&sindex=" + sindex+ "." +sindex1.tostring ();
Node1.id= "";
node1.target= "main";
if (sindex== "")
{
Sindex2=treeview1.nodes.indexof (NODE1). ToString ();
Sindex0=sindex2;
}
Else
{
Microsoft.Web.UI.WebControls.TreeNode Pnode=treeview1.getnodefromindex (Sindex);
PNODE.NODES.ADD (NODE1);
Sindex2=pnode.nodes.indexof (NODE1). ToString ();
Sindex0=sindex + "." + sIndex2;
sindex1++;//records the number of leaves under the current tree, that is, the number of the current leaf
}
Showdir (dtdatarow["Mlid"). ToString (), sIndex0);
}
Sqlcon.close ();
}
Current 1/3 page
123 Next read the full text