我正在使用telerik radgrid。我以编程方式绑定网格。网格正确加载但嵌套网格加载多次。(嵌套网格中列数的次数)。以下是我的代码
GridTableView tableViewOrders = new GridTableView(grid);
foreach (Application app in isParentApp)
{
DataTable tbl = new DataTable("nestedTable_" + app.AppId);
objGridList = GetGridList(app.AppId);
foreach (var nestedRow in objGridList)
{
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField = "AppId";
relationFields.DetailKeyField = "AppId";
tableViewOrders.ParentTableRelation.Add(relationFields);
GridBoundColumn boundColumn = new GridBoundColumn();
boundColumn.DataField = nestedRow.ColName;
boundColumn.HeaderText = nestedRow.ColName;
tableViewOrders.Columns.Add(boundColumn);
grid.MasterTableView.DetailTables.Add(tableViewOrders);
tbl.Columns.Add(nestedRow.ColName);
}
foreach(var rows in totalRows)
{
DataRow nestedDtRow = tbl.NewRow();
nestedDtRow["AppId"] = app.AppId;
foreach (var nestedRecord in nestedRecords)
{
nestedDtRow[nestedRecord.colName] = nestedRecord.Data;
}
tbl.Rows.Add(nestedDtRow);
}
tableViewOrders.DataSource = tbl;
}
虽然调试“tbl”只有一个表但输出显示多个表。
`
答案 0 :(得分:0)