GridView的当前页 [英] GridView current page

查看:176
本文介绍了GridView的当前页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何GridView的当前页面转换成数据表?

How to convert 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

这篇关于GridView的当前页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆