【发布时间】:2017-11-12 08:39:08
【问题描述】:
您好,我的要求是在引导树视图
中显示用户详细信息这里我通过 linq 查询从 SQL 数据库获取用户数据
这是示例 JSON 数据以这种方式如何在 C# 中准备数据
注意: 引导树视图仅适用于那些键名应与数据 text 和 nodes 中提到的相同但在我的 c# 类中我有不同的字段名称如下图所示
示例 JSON 数据 -->如何在 C# 中准备这样的数据
var treeData = [{
text: "UserName 1", nodes: [ {
text: "First Name1"
},
{
text: "Last Name1"
},
{
text: "User Orders 1",
nodes: [
{
text: "Order 1"
},
{
text: "Order 2"
}
]
},
{
text: "User Locations 1",
nodes: [
{
text: "Location 1"
},
{
text: "Location 2"
}
]
}
]
},
{
text: "UserName 2", nodes: [{
text: "First Name 2"
},
{
text: "Last Name 2"
},
{
text: "User Orders 2",
nodes: [
{
text: "Order 1"
},
{
text: "Order 2"
}
]
},
{
text: "User Locations 2",
nodes: [
{
text: "Location 1"
},
{
text: "Location 2"
}
]
}
]
}
];
【问题讨论】:
-
发布你需要转换成这种 JSON 格式的 C# 类
标签: c# json twitter-bootstrap asp.net-mvc-4 treeview