下面是我尝试使用的一个循环,用于将 GridViewRow 中的值获取到 DataRow 对象中(使用 Visual Basic 的 Godforsaken 语言)。但是,在这一行:
dr(i) = r.Cells(i).Text
我不断收到以下错误消息:
the value of type string cannot be converted to system.data.datarow
有人可以指出我如何做到这一点的正确方向吗?
Dim rows As New List(Of GridViewRow)()
For Each item As GridViewRow In grdExpProd.Rows
rows.Add(item)
Next
Dim value As Integer = rows.Count
Dim dt As New DataTable()
For index As Integer = value - 1 To 0 Step -1
Dim dr As DataRow()
Dim r As GridViewRow = rows(index)
For i As Integer = 0 To r.Cells.Count - 1
dr(i) = r.Cells(i).Text
Next
dt.Rows.Add(dr)
Next