I have a Repeater that forms panels with a left float in order to create a grid. My client only wants to show 12 elements per page, then have page numbers at the bottom of the page.
It would appear that everything is working, except I have an issue in that on the last page, if there aren't 12 elements, it loops back to the begining and shows the first elements again.
So if I have 20 elements total, the first 4 elements will be shown both at the top row of the first page and the last row of the second page.
Has anyone else ever seen this? Or can anyone otherwise assist me in having the repeater not loop to the first elements of the dataset?
Here's my code:
[PAGE CODE]
[CODE BEHIND]
It would appear that everything is working, except I have an issue in that on the last page, if there aren't 12 elements, it loops back to the begining and shows the first elements again.
So if I have 20 elements total, the first 4 elements will be shown both at the top row of the first page and the last row of the second page.
Has anyone else ever seen this? Or can anyone otherwise assist me in having the repeater not loop to the first elements of the dataset?
Here's my code:
[PAGE CODE]
Code:
<asp:Repeater ID="repeat_Gallery" runat="server"> <HeaderTemplate></HeaderTemplate> <ItemTemplate> <div style="float: left; width: 150px;"><%#Container.DataItem("myElementName")%></div> </ItemTemplate> <FooterTemplate> <div style="clear: both;"></div> </FooterTemplate> </asp:Repeater>
Code:
Public Property PageNumber() As Integer Get If ViewState("PageNumber") Is Nothing Then Return 0 Else Return Convert.ToInt32(ViewState("PageNumber")) End If End Get Set(ByVal value As Integer) ViewState("PageNumber") = value End Set End Property Public Sub GenerateElementsToRepeater() 'Pull Elements from Database Dim dataAdapt As New System.Data.SqlClient.SqlDataAdapter(sql, con) 'Fill DataSet with Art dataAdapt.Fill(_ds) 'Fill PagedDataSource with Dataset _pds.DataSource = _ds.Tables(0).DefaultView() _pds.AllowPaging = True _pds.PageSize = _PageSize _pds.CurrentPageIndex = PageNumber 'Bind to Repeater repeat_Gallery.DataSource = _pds repeat_Gallery.DataBind() End Sub