Repeater Paging

Just as we have the pageize property in gridview, which allows us to switch between pages, does not exist anyway, I can include the same functions in the repeater.

<table id="myTable"> <tbody> <asp:Repeater ID="Repeater1" runat="server" onitemcommand="addItem_OnClick" DataMember="DefaultView"> <ItemTemplate> <tr> <td> <div class="product"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td width="105"><asp:HyperLink ID="HLSysDet" runat="server" NavigateUrl='<%# "/Product.aspx?productId=" + Eval("ProductDescriptionId") %>'> <asp:Image ID="Image1" runat="server" width="85" height="85" ImageUrl='<%# Eval("Thumbnail")%>' border="0" /> </asp:HyperLink></td> <td><ItemTemplate><a href='<%# "/Product.aspx?productId=" + Eval("ProductDescriptionId") %>'> '<%# Eval("ProductName")%>'</a> </ItemTemplate></b><br /> <br /> Manufacturer: <%# Eval("Manufacturer")%><br /> <br /> <b>Rs <%# Eval("UnitPrice")%> </b><br /> <br /> Weight: <%# Eval("Weight")%> Kg<br /> </td> <td width="20"></td> <td valign="bottom" width="130"> <%# Eval("Quantity")%>+ in stock<br /> <asp:TextBox ID="_qty" runat="server" CssClass="textbox" MaxLength="2" Text="1" Width="30" Visible='<%# showBtn(Eval("Quantity")) %>' /> <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="_qty" ErrorMessage="*" ForeColor="Red" MaximumValue="50" MinimumValue="1"></asp:RangeValidator> <div class="buttons"><span id="Span1" class="mandatory" runat="server" visible='<%# isQty(Eval("Quantity")) %>'> Sorry, this item is out of stock</span></div> <div class="buttons"><br /> <asp:LinkButton ID="CommandButton" runat="server" Text='Add to Cart' CssClass="positive" CommandName="Add" CommandArgument='<%# Eval("ProductDescriptionId") %>' Visible='<%# showBtn(Eval("Quantity")) %>' /> </div> </td> </tr> </div> </table> </div> </td> </tr> </ItemTemplate> </asp:Repeater> </tbody> </table> <div class='pager'><a href='#' alt='Previous' class='prevPage'>Prev</a> <span class='currentPage'></span> of <span class='totalPages'></span> <a href='#' alt='Next' class='nextPage'>Next</a></div> 
+6
source share
3 answers

Check out http://plugins.jquery.com/project/paginateTable .

This is basically pagination on an html table (which you can build using a relay) using jQuery.

It is easy to use, has settings. I used it already, worked great.

EDIT

You will need to create a table with a repeater. I gave the following example:

 <table id="myTable"> <tbody> <asp:Repeater ...> <ItemTemplate> <tr><td><%# Eval('Description') %></td></tr> </ItemTemplate> </asp:Repeater> <tbody> </table> <div class='pager'> <a href='#' alt='Previous' class='prevPage'>Prev</a> <span class='currentPage'></span> of <span class='totalPages'></span> <a href='#' alt='Next' class='nextPage'>Next</a> </div> 

Your javascript should then call the paginateTable function on this

 <script> $(document).ready(function () { $('#myTable').paginateTable({ rowsPerPage: 2 }); }); </script> 
+4
source

Repeater and control offers a fast and flexible way to display data on an ASPX page. But it does not contain built-in swap functions.

However, you can do something about it ...

See the next page if you want to find out: http://www.codeproject.com/KB/webforms/Aspnet_Repeater_Control.aspx

+1
source

Source: https://habr.com/ru/post/885810/


All Articles