Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.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# 将记录追加到GridView_C#_Asp.net_Jquery - Fatal编程技术网

C# 将记录追加到GridView

C# 将记录追加到GridView,c#,asp.net,jquery,C#,Asp.net,Jquery,如果在网格视图的页脚中有“查看更多”按钮。当我点击它时,我需要从数据库中附加更多的记录,比如“FaceBook”。我需要这样做,而不使完整的职位回到网格上。 有没有办法使用jquery、Jason或其他任何东西来实现这一点呢?正如@Aristos所说,您将无法使用GridView来追加行,因为它绑定在服务器端。但是,您可以创建一个返回数据页的web服务。这些可以附加到您使用以下工具创建的: 然后从jQuery var currentPage = 0; var numPerPage = 30; $

如果在网格视图的页脚中有“查看更多”按钮。当我点击它时,我需要从数据库中附加更多的记录,比如“FaceBook”。我需要这样做,而不使完整的职位回到网格上。
有没有办法使用jquery、Jason或其他任何东西来实现这一点呢?

正如@Aristos所说,您将无法使用
GridView来追加行,因为它绑定在服务器端。但是,您可以创建一个返回数据页的web服务。这些可以附加到您使用以下工具创建的

然后从jQuery

var currentPage = 0;
var numPerPage = 30;
$.ajax({
    url: '/YourService.asmx/GetData',
    data: JSON.stringify({ 'offset': (numPerPage * ++currentPage), 'limit': numPerPage}),
    type: 'POST',
    dataType: 'json',
    contentType: 'application/json; charset=utf-8', 
    success: function(response){
        // response.d contains your formatted results. If you have a <ul>, you could append them simply by doing:
        $.each(response.d, function() {
            $('<li/>').html(this).appendTo('#yourList');
        });
    });
});
var currentPage=0;
var numPerPage=30;
$.ajax({
url:“/YourService.asmx/GetData”,
数据:JSON.stringify({'offset':(numPerPage*++currentPage),'limit':numPerPage}),
键入:“POST”,
数据类型:“json”,
contentType:'application/json;charset=utf-8',
成功:功能(响应){
//response.d包含格式化的结果。如果您有
    ,只需执行以下操作即可附加它们: $.each(response.d,function(){ $('
  • ').html(this.appendTo('#yourList'); }); }); });
如果使用grid view,则无法执行此操作,请尝试使用repeater。我可以获取使用repeater执行此操作的示例吗?是否需要GridView行中的服务器控件?您在
RowDataBound
事件处理程序中是否有任何服务器代码?是的,我需要RowDataBound和rowdommand的服务器端,但您不能异步执行此操作。只有在服务器上进行数据绑定时,此事件才可访问使用gridview、controls.add(gridview数据行)如何?它有用吗?
var currentPage = 0;
var numPerPage = 30;
$.ajax({
    url: '/YourService.asmx/GetData',
    data: JSON.stringify({ 'offset': (numPerPage * ++currentPage), 'limit': numPerPage}),
    type: 'POST',
    dataType: 'json',
    contentType: 'application/json; charset=utf-8', 
    success: function(response){
        // response.d contains your formatted results. If you have a <ul>, you could append them simply by doing:
        $.each(response.d, function() {
            $('<li/>').html(this).appendTo('#yourList');
        });
    });
});