我現在要實作treeview的動態實作多級效果,不知道哪位大蝦能幫幫忙,解決一下。
uj5u.com熱心網友回復:
什么動態多級喲,自己把問題說清楚一點嘛uj5u.com熱心網友回復:
在資料庫中記錄下項次所在的層級數,生成TREEVIEW的時候根據層級數來抓取資料就可以了uj5u.com熱心網友回復:
樹本身就是多層級的。uj5u.com熱心網友回復:
自己根據要求寫個USEROBJECT 就OK了,網上有的下uj5u.com熱心網友回復:
資料庫中中要有個記錄父級的編號 然后先加載第一層子級目錄 然后在itemchanged里面檢索子怒路就OK 了uj5u.com熱心網友回復:
dinguj5u.com熱心網友回復:
遞回系結多級樹TreeView(要求資料表中有子父級關系)2009-11-09 09:19
#region 將根節點系結,同時呼叫SetChildren方法遞回實作子節點的系結
/// <summary>
/// 將根節點系結,同時呼叫SetChildren方法遞回實作子節點的系結
/// </summary>
/// <param name="ds"></param>
public void bindTrees(DataSet ds)
{
DataRow[] datarow = ds.Tables[0].Select("ParentGuid is null");//篩選出根節點
foreach (DataRow dr in datarow)
{
TreeNode tn = new TreeNode();
tn.Text = dr["ContentName"].ToString();
tn.Value = dr["EntryGuid"].ToString();
TreeView1.Nodes.Add(tn);//將根節點系結到TreeView
tn.Target = "mainFrame";//連接地址指向主框架頁
tn.NavigateUrl = "Detail.aspx?entryGuid=" + tn.Value;
tn.Expanded = false;
SetChildren(tn, dr["EntryGuid"].ToString());//呼叫SelChildren實作遞回系結子節點
}
}
#endregion
#region 遞回實作子節點的系結
/// <summary>
/// 遞回實作子節點的系結
/// </summary>
/// <param name="tn">根節點</param>
/// <param name="id">根節點id</param>
public void SetChildren(TreeNode tn, string guid)
{
DataRow[] datarow = ds.Tables[0].Select("ParentGuid ='" + guid + "'");
foreach (DataRow dr in datarow)
{
TreeNode ctn = new TreeNode();
ctn.Text = dr["ContentName"].ToString();
ctn.Value = dr["EntryGuid"].ToString();
ctn.Target = "mainFrame";
ctn.NavigateUrl ="Detail.aspx?entryGuid=" + ctn.Value;
tn.ChildNodes.Add(ctn);
ctn.Expanded = false;
SetChildren(ctn, dr["EntryGuid"].ToString());//遞回
}
}
#endregion
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/100881.html
標籤:控件與界面
上一篇:讀取地磅資料
