C# 遞回 - 組ul
protected void Page_Load(object sender, EventArgs e)
{
string nodeStart = "15309";
GetTree(nodeStart);
}
private void GetTree(string parentId)
{
List<NodeBase> nodeList = SelectNode(parentId); //資料來源
if (nodeList.Count != 0)
{
this.treeStr += "<ul>";
foreach (NodeBase nb in nodeList)
{
this.treeStr += "<li id='" + nb.name + "'>" + "<a>" + nb.name + "</a>";
GetTree(nb.id);
this.treeStr += "</li>";
}
this.treeStr += "</ul>";
}
}
標籤: C#
0 個意見:
張貼留言
訂閱 張貼留言 [Atom]
<< 首頁