我在我的程序中使用ASP gridview来显示员工的记录。该数据包含大约60列。我已使用以下代码将列转换为行
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
FillGrid1()
End If
End Sub
Public Sub FillGrid1()
Dim strUnit As String
Dim intMonthYr As Integer
strUnit = Session("Unit")
intMonthYr = Session("MonthYr")
objReports.Unit = strUnit
objReports.ForMonth = intMonthYr
ds = objReports.MonthlyPayBill
Dim new_ds As New DataSet
new_ds = FlipDataSet(ds)
Dim my_DataView As DataView = new_ds.Tables(0).DefaultView
GridView1.DataSource = my_DataView
GridView1.DataBind()
End Sub
Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
Dim ds1 As New DataSet
Dim table As New DataTable()
For Each dt As DataTable In my_DataSet.Tables
For i As Integer = 0 To dt.Rows.Count
table.Columns.Add(Convert.ToString(i))
Next
Dim r As DataRow
For k As Integer = 0 To dt.Columns.Count - 1
r = table.NewRow()
r(0) = dt.Columns(k).ToString()
For j As Integer = 1 To dt.Rows.Count
r(j) = dt.Rows(j - 1)(k)
Next
table.Rows.Add(r)
Next
ds1.Tables.Add(table)
Next
Return ds1
End Function
60列被放置为60行,每个人被表示为一列。大约有50个人的记录,我想在列中进行分页,在每个页面中显示10个人,而不是在gridview中显示10个字段。