Click here to Skip to main content
15,887,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I can't pull the data into the Repeater. To use the data, I need to transfer it into the repeater, not the table. I've been calling online for days, but I haven't found an answer.

What I have tried:

JavaScript
$(function () {

            // Proxy created on the fly
            var job = $.connection.myHub;

            // Declare a function on the job hub so the server can invoke it
            job.client.displayStatus = function () {
                getData();
            };

            // Start the connection
            $.connection.hub.start();
            getData();
        });

        function getData() {
            var $tbl = $('#tbl');

            $.ajax({
                url: 'default3.aspx/GetData',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                type: "POST",
                success: function (data) {
                    debugger;
                    if (data.d.length > 0) {
                        var newdata = data.d;

                        $tbl.empty();
                        $tbl.append(' <tr><th>ID</th><th>Kullanıcı Adı</th><th>Şifre</th><th>SilindiMi</th><th>İşlemler</th></tr>');
                        var rows = [];

                        for (var i = 0; i < newdata.length; i++) {
                            rows.push(' <tr>');

                            rows.push('<td>' + newdata[i].id + '</td>');
                            rows.push('<td>' + newdata[i].kullaniciAdi + '</td>');
                            rows.push('<td>' + newdata[i].sifre + '</td>');
                            rows.push('<td>' + newdata[i].silindiMi + '</td>');

                            rows.push(' </tr>');
                        }
                        $tbl.append(rows.join(''));
                    }
                }
            });
        }


ASP.NET
<div>

            <table id="tbl"></table>
            <br />
            <hr />
            <div id="divRpt">
                <table>
                    <asp:Repeater ID="rptTbl" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <span class="id"><%# Eval("id") %></span>
                                </td>
                                <td>
                                    <span class="kullaniciadi"><%# Eval("kullaniciAdi") %></span>
                                </td>
                                <td>
                                    <span class="sifre"><%# Eval("sifre") %></span>
                                </td>
                                <td>
                                    <asp:LinkButton ID="lnkBton" CommandName="tiklaName" runat="server" Text="Tikla"></asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
            </div>
        </div>
Posted
Updated 19-Jul-18 18:01pm
Comments
Vincent Maverick Durano 19-Jul-18 20:41pm    
When you say "you can't pull the data", are you getting error? Does you getData() function returns anything?
Smthm 19-Jul-18 22:37pm    
I'm pulling the data, but I can't print it Repeater.

1 solution

Quote:
I'm pulling the data, but I can't print it Repeater.


See if this will work for you: https://www.aspsnippets.com/Articles/Bind-Populate-Repeater-control-with-JSON-object-using-jQuery-AJAX-in-ASPNet.aspx

Essentially, Data Representation Control such as Repeater is a Server Control. Server Controls should be binded at the server. If you want to use Repeater to display the data then you have to invoke the SignalR Hub method at the server, otherwise you need to build HTML table along with the data just like what you have right now.

Check the official documentation on how to: ASP.NET SignalR HUbs API Guide - Server
 
Share this answer
 
Comments
Smthm 20-Jul-18 5:47am    
I've seen this sample, but I can't reach the links in the repeater. "Repeater. OnItemCommand" method
Vincent Maverick Durano 21-Jul-18 0:08am    
OnItemCommand is a server event, so you can’t invoke it at the client.
Smthm 21-Jul-18 6:55am    
Thank you for your help.
Vincent Maverick Durano 22-Jul-18 23:55pm    
you bet. Glad to be of help! :)

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