asp.net unlimited category 1th/3 page _ Practical Tips

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.