【发布时间】:2015-07-08 06:50:15
【问题描述】:
我正在使用 treetable.js。作为程序,我保存了子 ID 和父 ID。 insert 数据插入成功。但返回数据可能仅显示在表格中或出现分组错误。 然后我使用 IGrouping 对象得到转换错误。 请告诉我下面的子父循环结构。
在模型中:
public string name {get;set;}
public int childId {get;set;}
public int ParentId {get;set;}
在控制器中:
var list = db.table.groupby(s=>s.parentId).toList();
return view(list);
鉴于:
<table id="example-basic">
<tr>
<th>Name</th>
<th>Data Id</th>
<th>Parent Id</th>
</tr>
@foreach (var item in Model)
{
<tr data-tt-id='@item.dataid' data-tt-parent-id='@item.dataparentid'>
<td>@item.Name</td>
<td>@item.dataid</td>
<td>@item.dataparentid</td>
</tr>
}
</table>
【问题讨论】:
-
什么是“转换错误”?还是“分组错误”?如果您列出您收到的错误,则更容易为您的问题提供准确的答案。
-
ChildId是你的行Id,我猜对了吗? -
传入字典的模型项的类型为“System.Collections.Generic.List
1[System.Linq.IGrouping2[System.Nullable1[System.Int32],Project_Cost_Management_System.Models.ChartOfAccount]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[Project_Cost_Management_System.Models.ChartOfAccount]”。 -
不,ID 在 GUID @teovankot
标签: asp.net-mvc razor asp.net-mvc-5 parent-child