Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > C#/.NET技巧

asp.net 无限分类第1_3页

来源:中文源码网    浏览:194 次    日期:2024-05-11 17:50:59
【下载文档:  asp.net 无限分类第1_3页.txt 】


asp.net 无限分类第1/3页
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下一页阅读全文

相关内容