Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have tried to convert this repeater below to a jquery dataTable but i cant get to make it work. How do i achieve this or is there a better tool i can use to handle pagination out there? i'm using asp.net webform

What I have tried:

<pre><asp:Repeater ID="RepeaterRecord" runat="server" OnItemDataBound="RepeaterRecord_ItemDataBound" ClientIDMode="Static">
                                            <HeaderTemplate></HeaderTemplate>
                                            <ItemTemplate>
                                                    <div class="single-prodcut-img  product-overlay pos-rltv">
                                                        <a href="Singleproduct.aspx?Product=<%#Eval("Product_Id") %>">  <asp:Image ID="ProductImage" runat="server" class="primary-image" ImageUrl='<%#"data:Image/jpg;base64,"+ Convert.ToBase64String((byte[])Eval("Product_Image1")) %>'/></a>
                               </div>
         <div class="prodcut-name"> <a href="Singleproduct.aspx?Product=<%#Eval("Product_Id") %>"><%#Eval("Product_Name") %></a> </div>
                                                            <div class="new-price"><%# "N" +Eval("Product_Price") %></div>

                                                </ItemTemplate>

                                            </asp:Repeater>













<script type ="text/javascript">
    $(document).ready(function () {

        $('#RepeaterRecord').prepend($("<thead></thead>").append($('#RepeaterRecord').dataTable({
            responsive: true,
            "paging": true,
            "bAutoWidth": false,
            "searching": true,
            "iDisplayLength": 5,
            "aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]]
        });
    });
    </script>
Posted
Updated 2-May-17 23:45pm
Comments
F-ES Sitecore 3-May-17 7:38am    
There are lots of ways of doing pagination but you haven't indicated if you want the pagination on the server, on the client, or a mix of both with ajax so it's impossible to give specific advice. Google "asp.net repeater pagination" and you'll find lots of examples. Go through some and see what ones work for you.
Mcbaloo 3-May-17 8:08am    
well, i'm developing an application that might have huge data saved in the database. i also want to know which(sever side, client side or both) would be suitable for efficiency. Also might need to simple example to help continue where i am currently stucked

1 solution

Best way in my opinion is to maken the paging from the controller so let asp.net handling this.

This is a nice (working) example Example asp.net mvc pagination[^]

Also if you really want to do this client sided than you can have a look at Angular I really love those features Angular example[^]

A Fiddle example with javascript: pagination example

I would definitely not running a pagination with jquery and hard coded paging lists. 5, 10, 25, 50, "All" is never going to change when there are more than 50 in your case. That makes the paging useless.
 
Share this answer
 
v3
Comments
Mcbaloo 3-May-17 6:13am    
I don't really use Angular and can't seems to write a controller since i'm not using MVC although, i'm still a rookie. I have used dataTable with gridView but i used a table format. Since i am using a repeater and a div this time around, i need a new way round it
Wessel Beulink 3-May-17 6:23am    
Take a look at the Fiddle example i pasted in the solution
F-ES Sitecore 3-May-17 7:30am    
He's not using MVC though

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900