我有两个DataTable
的数据:
dtTree = "SELECT UnqID, category FROM ExpressionCategorys"
dtTreeInner = "SELECT Name FROM Expressions WHERE FK_Category = '{" & dtTree.Rows(i)("UnqID").ToString & "}'
我的问题是,我可以在下面给出这么长的编码方式,但是如何将数据从DataTable
传递到List
(因为dtTree
是父节点, dtTreeInner
是子节点??
-Expressions (topnode static)
--Standard (childnode of Expressions - this data comes from dtTree)
--- ApplicationRef (childnode - this data comes from dtTreeInner )
--- ApplicationStat (childnode - this data comes from dtTreeInner )
--- Longdate (childnode - this data comes from dtTreeInner )
--- ShortDate (childnode - this data comes from dtTreeInner )
--Address (childnode of Expressions - this data comes from dtTree)
如何使用for
循环自动完成此过程?
注意:我正在尝试在ASP.NET MVC中创建TreeView
public class Node
{
public int NodeID { get; set; }
public string NodeName { get; set; }
public string NodeText { get; set; }
public eNodeType NodeType { get; set; }
public List <Node> Childern { get; set; }
public string NodeParent { get; set; }
public string FirstParent { get; set; }
}
List<Node> nodes = new List<Node>();
nodes.Add(
new Node() //Expressions
{
NodeID = 0, NodeName = "nExp", NodeType = eNodeType.Exp, NodeText = "Expressions",
Childern = new List<Node>()
{
new Node () //Standard
{
NodeID = 1,NodeName = "Standard",NodeType = eNodeType.Exp,NodeText = "Standard",NodeParent ="Expressions",FirstParent="Expressions",
Childern = new List<Node>()
{
new Node () {NodeID = 2, NodeName = "[*Application Reference]",NodeType = eNodeType.Data,NodeText = "[*Application Reference]",NodeParent ="Standard",FirstParent="Expressions" },
new Node () {NodeID = 3, NodeName = "[*Application status]",NodeType = eNodeType.Data,NodeText = "[*Application status]",NodeParent ="Standard",FirstParent="Expressions"},
new Node () {NodeID = 4, NodeName = "[*Long Date]",NodeType = eNodeType.Data,NodeText = "[*Long Date]",NodeParent ="Standard",FirstParent="Expressions"},
new Node () {NodeID = 5, NodeName = "[*Short Date]",NodeType = eNodeType.Data,NodeText = "[*Short Date]",NodeParent ="Standard",FirstParent="Expressions"}
}
}
}