使用jQuery附加值时,在GridView中分页不起作用

时间:2013-02-14 07:26:36

标签: c# jquery asp.net ajax

这里我有一个gridview,我使用jquery将检索到的数据附加到它。我想在gridview中使用分页。但它没有用。我不知道为什么..因为当我在其他应用程序中使用相同的方法时,它通常没有jquery绑定网格,它完全正常。请查看我的代码并告诉我出了什么问题

这是我的网格,

<form runat="server">
   <asp:GridView ID="GridView1" ClientIDMode="Static" runat="server" AutoGenerateColumns="False" AllowPaging="True" PageSize="5" GridLines="None" CellSpacing="10" >

   </asp:GridView>

这是我的jquery代码,它将值(绑定)附加到网格

$("#search-user")
       .button()
       .click(function () {
           $.ajax({
               contentType: "application/json; charset=utf-8",
               url: "MyHandler.ashx",
               data: {
                   'user': "" + $("#txtsearch").val(),
                   'method': 'search'
               },
               dataType: "json",
               success: updateGrid,
               error: function (result) { alert("Error- Inside user Searching "); }
                });
       });

function updateGrid(data) {
        var i = 0;
        var content;
        $("#GridView1").html('');  // clearing the old data in grid
        $("#GridView1").append("<tr><th>" + "Name" + "</th><th>" + "Gender" + "</th><th>" + "Date of Birth" + "</th><th>" + "Role" + "</th><th>" + "Password" + "</th><th>" + "Email" + "</th></tr>"); 


 while (data[i] != null)
        {  // appending the retrieved data to grid
            $("#GridView1").append("<tr><td>" + data[i].name + "</td><td>" + data[i].gender + "</td><td>" + data[i].dob + "</td><td>" + data[i].role + "</td><td>" + data[i].password + "</td><td>" + data[i].email + "</td></tr>");
            i++;
        }
    }

0 个答案:

没有答案