asp.net 无限分类第1/3页

(编辑:jimmy 日期: 2024/10/5 浏览:2)

1、递归函数

//  '递归遍历自建目录树=============================================================================

  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;//记录树的最后一位值
   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++;//记录当前树下叶子的个数,即当前叶子的号
    }
    ShowDir(DtDataRow["mlid"].ToString(),sIndex0);

   
   }
   sqlCon.Close();

  }

123下一页阅读全文
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。