Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用jQuery追加值时,在GridView中分页不起作用_C#_Jquery_Asp.net_Ajax - Fatal编程技术网

C# 使用jQuery追加值时,在GridView中分页不起作用

C# 使用jQuery追加值时,在GridView中分页不起作用,c#,jquery,asp.net,ajax,C#,Jquery,Asp.net,Ajax,这里有一个gridview,我使用jquery将检索到的数据附加到它。我想在gridview中使用分页。但它不起作用。我不知道为什么。。因为当我在其他应用程序中使用相同的方法,在没有jquery的情况下正常绑定网格时,它工作得非常好。请检查我的代码并告诉我出了什么问题 这是我的网格 <form runat="server"> <asp:GridView ID="GridView1" ClientIDMode="Static" runat="server" AutoGene

这里有一个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代码,它将值(bind)附加到网格中

$("#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++;
        }
    }
$(“#搜索用户”)
.按钮()
。单击(函数(){
$.ajax({
contentType:“应用程序/json;字符集=utf-8”,
url:“MyHandler.ashx”,
数据:{
“用户”:“+$(“#txtsearch”).val(),
“方法”:“搜索”
},
数据类型:“json”,
成功:updateGrid,
错误:函数(结果){alert(“错误-内部用户搜索”);}
});
});
函数updateGrid(数据){
var i=0;
var含量;
$(“#GridView1”).html(“”);//清除网格中的旧数据
$(“#GridView1”)。追加(“+”姓名“+”性别“+”出生日期“+”角色“+”密码“+”电子邮件“+”);
while(数据[i]!=null)
{//将检索到的数据追加到网格
$(“#GridView1”)。追加(“+数据[i]。名称+”+数据[i]。性别+”+数据[i]。dob+”+数据[i]。角色+”+数据[i]。密码+”+数据[i]。电子邮件+);
i++;
}
}

尝试jqgrids而不是asp grids。请参阅此链接