C# 使用嵌套字典填充树视图

C# 使用嵌套字典填充树视图,c#,asp.net,dictionary,treeview,C#,Asp.net,Dictionary,Treeview,我有一张这样的管理桌 ID Name Parent 1 Manager 0 2 Accountant 0 3 Assistant Manager 1 4 Branch Manager 1 5 Employee1 3 6 Employee3 3 7 Employee2 4 8 Accountant1 2 9

我有一张这样的管理桌

ID    Name           Parent
1   Manager             0
2   Accountant          0
3   Assistant Manager   1
4   Branch Manager      1
5   Employee1           3
6   Employee3           3
7   Employee2           4
8   Accountant1         2
9   Accountant2         2
在我的asp页面中,父视图表示这样的树视图结构

*Manager-->Assistant manager-->Employee1
        |                   |->Employee3
        |
        |-->Branch Manager---->Employee2
*Accountant-->Accountant1
           |->Accountant2    
我只需要使用dictionary向treeview显示我的数据表 所以我编写了以下代码将datatable绑定到字典。 我需要从上面的嵌套字典中获取字符串值。怎么做

management = dt.AsEnumerable()
               .GroupBy(m => m.Field<int>("ID"))
               .ToDictionary(
                   a => a.Key,
                   a => a.GroupBy(c => c.Field<string>("Name"))
                         .ToDictionary(
                             d => d.Key,
                             d => d.First().Field<int>("Parent")));
我也知道我的代码隐藏还没有完成。请帮忙 我是asp的新手


伙计们还没有帮助:(

伙计们,你还知道帮助吗?抱歉,打字打错了:伙计们为什么还没有帮助?system.windows.forms.treeview和system.web.ui.WebControl.treeview是不同的treeview。节点是窗体(桌面应用程序)属性,错误消息指向WebControl(ASP)控件。
public void DisplayTree()
{
    try
    {
        TreeNode parentnode = new TreeNode();
        ManagementBL l_bl_manag = new ManagementBL();
        Dictionary<int, Dictionary<string, int>> manage = new Dictionary<int, Dictionary<string, int>>();
        manage = l_bl_manag.Adddictionary();
        foreach (var kvp in manage)
        {
            var innerdict = kvp.Value;
            foreach (var innerkvp in innerdict)
            {
                parentnode = new TreeNode(innerkvp.Key);
                parentnode.Text = innerkvp.Key; 
                if (kvp.Key == innerkvp.Value)
                {
                    parentnode.ChildNodes.Add(new TreeNode(innerkvp.Key));
                }
            }
            tv_Management.Nodes.Add(parentnode);
        }
        this.Controls.Add(tv_Management);
    }

    catch (Exception ex)
    {
        string error = ex.Message.ToString();
        lb_msg.Text = "Unknown error on this page. Please try again later";
    }
}
Control 'tv_Management' of type 'TreeView' must be placed inside a form tag with runat=server.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Control 'tv_Management' of type 'TreeView' must be placed inside a form tag with runat=server.