0
I have create table in database name"Group" contains ID,Rank,Name like this:
ID RANK NAME
1 A Main
2 A1 Departments
3 A2 Companies
4 A3 Usres
5 I Invoice
6 T Tools
7 T1 ChangPswd
8 T2 ChangLanguage
when I try this query get the same result
我該如何讓'A + T'is parent(A1,A2,A3,T1,T2)是childnode? (在同一個表中) SELECT排名,名稱, 排名()排序(按排名排序)排名 從組 排序方式ID;TreeView如何做到這一點?
//in formLoad
{
DataTable dt;
DBAccess db = new DBAccess();
dt = db.ExcuteDataTable("SELECT Name FROM Group")
foreach (DataRow dr in dt.Rows)
{
parentNode = Tree.Nodes.Add(dr["Name"].ToString());
}
how can i make 'A+T'is parent and (A1,A2,A3,T1,T2) is childnode? (in the same table)
我會建議如果可能的話改變你的表的架構。將Rank字段更改爲一個int,該int是同一個表上ID字段的外鍵。然後,您可以通過內部加入表格來輕鬆選擇節點的子節點。 – 2014-09-25 23:31:53