2013-01-24 124 views
1

如果在网格视图的页脚中有'see more'按钮。当我点击它时,我需要从数据库中追加更多记录,如“Face Book”。我需要这样做,而不是完全发回网格。 有没有办法使用J Query,Jason或其他任何东西来做到这一点将记录添加到GridView中

+0

借助网格视图,你不能做到这一点,尝试中继器。 – Aristos

+0

我可以得到一个使用中继器的例子吗? –

+0

GridView行中是否需要服务器控件? 'RowDataBound'事件处理程序中是否有任何服务器代码? –

回答

0

正如@Aristos所说的,您将无法使用GridView追加行,因为它在服务器端绑定。但是,您可以创建一个返回数据页面的Web服务。这些可以被添加到您已与a repeater创建一个<ul>

[WebMethod] 
[ScriptMethod(ResponseFormat=ResponseFormat.Json)] 
public string Format(int offset, int limit) { 
    // return data from your database here 

再从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'); 
     }); 
    }); 
}); 
+0

如何使用gridview,controls.add(gridview数据行)?它有用吗? –