高兴,学习中量变到质变,ASP.NET 2.0 树型数据的显示源代码(原创,用递归)
高兴,学习中量变到质变,ASP.NET 2.0 树型数据的显示源代码(原创,用递归)<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Data;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Data.SqlClient;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Configuration;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web.Security;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web.UI;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web.UI.WebControls;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web.UI.WebControls.WebParts;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifusingSystem.Web.UI.HtmlControls;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifpublicpartialclass_Default:System.Web.UI.Page
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifSqlConnectionconn=newSqlConnection("workstationid="cyz";userid=sa;password=****;initialcatalog=pubs;persistsecurityinfo=false");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifDataSetds=newDataSet();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifprotectedvoidPage_Load(objectsender,EventArgse)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifif(!(IsPostBack))
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifSqlDataAdapterda=newSqlDataAdapter("select*fromt_treeorderbyparentid",conn);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifda.Fill(ds,"t_tree");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifInitTree0();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifprivatevoidInitTree0()//根结点加载函数
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifTV.Nodes.Clear();//TV为TreeView控件
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifDataRow[]rows=ds.Tables["t_tree"].Select("parentid=0");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giffor(inti=0;i<rows.Length;i++)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifTreeNodeT_root=newTreeNode();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifDataRowdr=rows;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifT_root.Text=dr["Descricpt"].ToString();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifTV.Nodes.Add(T_root);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifInitTree(T_root,dr["id"].ToString());//根结点加载完后,开始调用加载子结点的函数,并开始递归。
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifprivatevoidInitTree(TreeNodeNd,StringParent_id)//子树结点加载函数
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifDataRow[]rows=ds.Tables["t_tree"].Select("parentid="+Parent_id);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifif(rows!=null)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.giffor(inti=0;i<rows.Length;i++)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifTreeNodeTnd=newTreeNode();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifDataRowdr=rows;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifTnd.Text=dr["Descricpt"].ToString();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifNd.ChildNodes.Add(Tnd);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gifInitTree(Tnd,dr["id"].ToString());//递归调用
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
页:
[1]