我正在尝试在转发器控件中创建寻呼机。内容正在从数据库中提取并显示,但是当我单击上一个和下一个按钮时,它们不会分页,也就是说,我停留在相同的内容上。任何人都可以从下面的代码中看到错误吗?没有错误或显示,所以我认为这是小问题,但我一直在用头撞墙试图找到它
标记:
<asp:Repeater ID="ArtRepeater" runat="server">
<HeaderTemplate>
<h2>Items in Selected Category:</h2>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink runat="server" ID="HyperLink"
NavigateUrl='<%# Eval("MovieID", "Default2.aspx?ArtID={0}")%>'>
<%# DataBinder.Eval(Container.DataItem, "MovieTitle")%>
</asp:HyperLink>
</li>
</ItemTemplate>
代码背后:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
doPaging()
End Sub
Function getTheData() As DataTable
Dim DS As New DataSet()
Dim strConnect As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & _
Server.MapPath("/App_Data/MovieBoard.accdb"))
Dim objOleDBAdapter As New OleDbDataAdapter("SELECT MovieID, MovieTitle FROM Movies", strConnect)
objOleDBAdapter.Fill(DS, "Movies")
Return DS.Tables("Movies").Copy
End Function
Sub doPaging()
pagedData.DataSource = getTheData().DefaultView
pagedData.AllowPaging = True
pagedData.PageSize = 1
Try
pagedData.CurrentPageIndex = Int32.Parse(Request.QueryString("Page")).ToString()
Catch ex As Exception
pagedData.CurrentPageIndex = 0
End Try
btnPrev.Visible = (pagedData.IsFirstPage)
btnNext.Visible = (Not pagedData.IsLastPage)
pageNumber.Text = (pagedData.CurrentPageIndex + 1) & " of " & pagedData.PageCount
ArtRepeater.DataSource = pagedData
ArtRepeater.DataBind()
End Sub