46
A
回答
114
DataView對象本身用於遍歷DataView行。
DataView行由DataRowView對象表示。 DataRowView.Row屬性提供對原始DataTable行的訪問。
C#
foreach (DataRowView rowView in dataView)
{
DataRow row = rowView.Row;
// Do something //
}
VB.NET
For Each rowView As DataRowView in dataView
Dim row As DataRow = rowView.Row
' Do something '
Next
2
//可以轉換數據視圖表。使用DataView.ToTable();
foreach (DataRow drGroup in dtGroups.Rows)
{
dtForms.DefaultView.RowFilter = "ParentFormID='" + drGroup["FormId"].ToString() + "'";
if (dtForms.DefaultView.Count > 0)
{
foreach (DataRow drForm in dtForms.DefaultView.ToTable().Rows)
{
drNew = dtNew.NewRow();
drNew["FormId"] = drForm["FormId"];
drNew["FormCaption"] = drForm["FormCaption"];
drNew["GroupName"] = drGroup["GroupName"];
dtNew.Rows.Add(drNew);
}
}
}
//或者你可以使用
// 2.
dtForms.DefaultView.RowFilter = "ParentFormID='" + drGroup["FormId"].ToString() + "'";
DataTable DTFormFilter = dtForms.DefaultView.ToTable();
foreach (DataRow drFormFilter in DTFormFilter.Rows)
{
//Your logic goes here
}
0
我寧願做一個更直接的方式。它沒有行,但仍然有行數組。
tblCrm.DefaultView.RowFilter = "customertype = 'new'";
qtytotal = 0;
for (int i = 0; i < tblCrm.DefaultView.Count; i++)
{
result = double.TryParse(tblCrm.DefaultView[i]["qty"].ToString(), out num);
if (result == false) num = 0;
qtytotal = qtytotal + num;
}
labQty.Text = qtytotal.ToString();
相關問題
- 1. 在ruby中循環遍歷
- 2. 遍歷錶行的循環
- 3. Jquery循環遍歷錶行
- 4. 循環遍歷錶行
- 5. 循環遍歷行QTableWidget
- 6. 循環遍歷LinkedList
- 7. 循環遍歷SQL表中的行
- 8. 循環遍歷Silverlight DataGrid中的行
- 9. 未循環遍歷循環 - javascript
- 10. 在Python中循環遍歷數字
- 11. 在bash中循環遍歷數組
- 12. 在Swift中循環遍歷NSMutableArray
- 13. 在PHP中循環遍歷一個JSON
- 14. 在Laravel中循環遍歷對象
- 15. 在boost :: unordered_multimap中循環遍歷equal_range
- 16. 在PL/SQL中循環遍歷字
- 17. 循環遍歷逐行的範圍
- 18. Html Agility Pack - 循環遍歷行和列
- 19. 循環遍歷行和列Excel宏VBA
- 20. python beautifulsoup循環遍歷表格行
- 21. 循環遍歷範圍,行和列
- 22. 使用Javascript循環遍歷錶行/ Jquery
- 23. 循環遍歷一個NSMutableArray
- 24. 循環遍歷JavaScript JavaScript
- 25. xquery循環遍歷列
- 26. Django循環遍歷列表
- 27. 遞歸循環遍歷類
- 28. 循環遍歷表列
- 29. MySQL循環遍歷列
- 30. Angularjs循環遍歷表