0
我正在使用telerik radgrid。我以編程方式綁定網格。網格正確加載,但嵌套網格多次加載(嵌套網格中的列數)。下面是我的代碼c#嵌套網格加載多次
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」只有一個表,但輸出顯示的多個表。
`
嗨,這個循環只添加一列......「objGridList」實際上有列名稱列表。 – user3064309
當我調試「tbl」只有一個表。但輸出顯示很多表 – user3064309
您正在爲每行添加一次 – CodingYoshi