2013-07-16 52 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 :)
祝您好運!