Looping through rows in a DataView

前端 未结 4 1332
鱼传尺愫
鱼传尺愫 2020-12-09 07:30

The DataView object doesn\'t have a Rows property like DataTable.

How do I loop through the rows of a DataView?

4条回答
  •  清歌不尽
    2020-12-09 08:03

    The DataView object itself is used to loop through DataView rows.

    DataView rows are represented by the DataRowView object. The DataRowView.Row property provides access to the original DataTable row.

    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
    

提交回复
热议问题