Försöker med hjälp av exempel här på Pellesoft Paging i en Repeater
fixa till paging i en repeater.
ASP.NET 2.0
MySQL
Denna sub fungerar och skriver ut de 16 poster som finns
i en repeater
Sub FillRepeater(ByVal AvdID As Integer, ByVal Sida As Integer)
Dim Sql As New StringBuilder
Dim ItemCount As Integer = 0
Dim CurrItem As String = ""
Sql.Length = 0
Sql.Append("SELECT T.*, A.NameShort ")
Sql.Append(" FROM tbl_Test T, tbl_Avd A ")
Sql.Append(" WHERE T.AvdID = A.AvdID ")
Sql.Append(" AND T.AvdID = " & AvdID)
Sql.Append(" ORDER BY T.Enamn")
Try
Dim ds As DataSet = clsReturnDataset(Sql.ToString)
With Me.Repeater1
.DataSource = ds
.DataBind()
End With
Catch ex As Exception
End Try
btnUpdate.Visible = True
End Sub
Sen försöker jag med paging koden nedan
Sub FillRepeater(ByVal AvdID As Integer, ByVal Sida As Integer)
Dim Sql As New StringBuilder
Dim ItemCount As Integer = 0
Dim CurrItem As String = ""
Sql.Length = 0
Sql.Append("SELECT T.*, A.NameShort ")
Sql.Append(" FROM tbl_Test T, tbl_Avd A ")
Sql.Append(" WHERE T.AvdID = A.AvdID ")
Sql.Append(" AND T.AvdID = " & AvdID)
Sql.Append(" ORDER BY T.Enamn")
Try
Dim ds As DataSet = clsReturnDataset(Sql.ToString)
Dim objPDS As PagedDataSource = New PagedDataSource
With objPDS
.DataSource = ds
.AllowPaging = True
.PageSize = 5
.CurrentPageIndex = 0
End With
With Me.Repeater1
.DataSource = objPDS
.DataBind()
End With
Catch ex As Exception
End Try
btnUpdate.Visible = True
End Sub
, och får då felmeddelandet
Unable to cast object of type 'System.Data.DataSet' to type 'System.Collections.IEnumerable'.
på rad
objPDS.DataSource = ds
Vad göra??