Hi @Federico R ,
According to the code you provided, you did not set the PagedControlID. When the PagedControlID is set, the problem you mentioned will not occur.
- <asp:DataPager ID="DataPager" PageSize="20" class="btn-group btn-group-sm" runat="server" OnPreRender="Page_Load" PagedControlID="TestListView" >
- <asp:ListView ID="TestListView"
Here is an example, you can refer to it.
Page:
- You can click this link to download the file to view the code.
xxx.aspx.cs
Public Partial Class _Default
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
TestListView.DataSource = testdata()
TestListView.DataBind()
End Sub
Public Function testdata() As DataTable
Dim table As DataTable = New DataTable()
Dim column As DataColumn
Dim row As DataRow
table.Columns.Add(New DataColumn With {
.DataType = Type.[GetType]("System.String"),
.ColumnName = "TestId"
})
table.Columns.Add(New DataColumn With {
.DataType = Type.[GetType]("System.String"),
.ColumnName = "TestName"
})
For i As Integer = 1 To 500 - 1
row = table.NewRow()
row("TestId") = i.ToString()
row("TestName") = "TestName" & i.ToString()
table.Rows.Add(row)
Next
Return table
End Function
End Class
Result
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
YihuiSun