开发者

GridView current page

How to conver开发者_C百科t GridView's current page into DataTable?


You could try this (untested and incomplete):

Dim tbl As New DataTable
For Each col As DataControlField In MyGrid.Columns
    tbl.Columns.Add(New DataColumn(col.HeaderText))
Next
For Each row As GridViewRow In MyGrid.Rows
    Dim params As New List(Of Object)
    For Each cell As TableCell In row.Cells
        Dim cellText As String = String.Empty
        For Each ctrl As Control In cell.Controls
            If TypeOf ctrl Is Label Then
                cellText = DirectCast(ctrl, Label).Text
                Exit For
            ElseIf TypeOf ctrl Is TextBox Then
                cellText = DirectCast(ctrl, TextBox).Text
                Exit For
                'to be continued....'
            End If
        Next
        params.Add(cellText)
    Next
    tbl.Rows.Add(params.ToArray)
Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜