【发布时间】:2014-03-22 04:31:06
【问题描述】:
我需要从上面的嵌套字典中获取字符串值。怎么做。 我有从数据表 [3 列] 到字典的 keypairvalue,像这样
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")));
string temp = 管理???
编辑:让我详细说明一下。
我有一个这样的管理表
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
我只需要使用字典将我的数据表显示到树视图 所以我做了上面的代码来将数据表绑定到字典。 现在尝试将字典绑定到树视图 是清楚的伙伴吗 PS:我是asp新手
【问题讨论】:
-
你需要提取什么样的值?只是
"Name"s? -
我还需要“id”和“parent”。如果你告诉我如何从“name”中获取第一个字符串值和某些字符串值,那么我会管理的。字典有 9 行 btw
标签: c# asp.net dictionary