2013-07-16 50 views
3

如何在C#ASP.net中创建DataGrid,以便拖放行以对其重新排序。我想从工具箱中使用实际的DataGrid工具,而不是相像。拖放DataGrid

+2

我不认为'DataGrid'控件具有开箱即用的功能。您可能可以在客户端使用jQuery UI Draggable重新排列视图中的行,但这不会影响实际数据中服务器端的任何内容,除非您将某种更新发送到服务器端处理程序(如AJAX调用)。 – David

回答

1

HERE是演示!

正如David所说,您可以使用JQuery拖放DataGrid的'行!

<script type="text/javascript"> 
$(function() { 
    $(".drag_drop_grid").sortable({ 
     items: 'tr:not(tr:first-child)', 
     cursor: 'crosshair', 
     connectWith: '.drag_drop_grid', 
     axis: 'y', 
     dropOnEmpty: true, 
     receive: function (e, ui) { 
      $(this).find("tbody").append(ui.item); 
     } 
    }); 
    $("[id*=gvDest] tr:not(tr:first-child)").remove(); 
}); 

,你可以找到一个完整的参考HERE :)
祝您好运!