2012-11-16 43 views
0

我動態結合我的網格,LINQ表達的結果在pageLoad的,並在HtmlRowPrepared事件我試圖達到與ASPxGridView.GetChildDataRow總是空

for (int i = 0; i < grid.GetChildRowCount(visibleGrIndex); i++) 
    { 
    var row = grid.GetChildDataRow(visibleGrIndex, i); 
    } 

但它總是空一個DataRow?

回答

1

HtmlRowPrepared對於每個網格行都會觸發一次。 所以,你可以使用此代碼來獲取數據行:

private void Grid_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { 
    if (e.RowType == GridViewRowType.Group) 
    { 
     for (int i = 0; i < GetChildRowCount(e.VisibleIndex); i++) 
     { 
      var row = GetChildDataRow(e.VisibleIndex, i); 
     } 
    } 
} 
+0

非常感謝你,但我不想達到指定行,我想遍歷行中任何指定的組行? DevX文檔說,GetChildRowCount()返回給定組行的子行數,GetChildDataRow()返回組行中的DataRow,該行指定了該組中該行的從零開始的索引。第一種方法效果很好,但第二種方法總是空的:( – DortGen

+0

我已經更新了我的答案。更新後的代碼在我的應用程序中正常工作 – Filip

+0

仍然存在問題繼續...在調試分配線上,行是「本地值或參數值」行'在這個時候是無法獲得的。「當我將它放到nullcheck時,它會顯示爲null :( – DortGen