0

I have a gridView which is movable with dragAndDrop. But i am able only for move the row of gridView using dragAndDrop. This is my code:

gridView1.datasource = dt;
gridView1.dataBind();

<asp:GridView ID="GridView3" CellPadding="5" CellSpacing="0"  
              OnRowDataBound="GridView3_RowDataBound"
              ForeColor="#333" runat="server" 
              AutoGenerateColumns="true">
</asp:GridView>

<asp:Button ID="Save" runat="server" Text="Save" onclick="btnsave_Click" />

// use of JQuery for dragAndDrop
$(function () {
        $("[id*=GridView1]").sortable({
            items: 'tr:not(tr:first-child)',
            cursor: 'pointer',
            axis: 'y',
            dropOnEmpty: false,
            start: function (e, ui) {
                ui.item.addClass("selected");
            },
            stop: function (e, ui) {
                ui.item.removeClass("selected");
            },
            receive: function (e, ui) {
                $(this).find("tbody").append(ui.item);
            }
        });
    });

Using this code, i am only able to move rows of gridView. But i want, when i will click on save button then the order of rows which are changed by dragAndDrop will be shown. thanks.

Kjartan
  • 18,591
  • 15
  • 71
  • 96
Annoy
  • 1
  • I think you should create a field sort, which is not shown in the GridView. But you sort with that. Then the first has value 1, second = 2 .... – Presi Sep 12 '19 at 10:38
  • @Presi Can u give any idea, how can i do. u have any link or code something? – Annoy Sep 12 '19 at 10:53
  • Maybe this can help you: https://stackoverflow.com/questions/56985719/implementing-ordering-for-list-of-objects-in-c-sharp-and-methods-for-changing-th/56985811#56985811 – Presi Sep 12 '19 at 12:06

0 Answers0