Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a gridView which is movable with dragAndDrop. I am using JQuery for dragAndDrop the row of gridView. The row of gridView is moving but after move the row of gridView, the index(order) of row is not changing.
I want to change the row index of gridView.
I am using this code:

What I have tried:

<script type="text/javascript">
        $(function () {
            $("[id*=GridView2]").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);
                },
                update: function (e, ui) {               
                    var newOrder = $(this).sortable('toArray').toString();
                    $.get('Default.aspx', { order: newOrder });
                }
            });
        });
             </script>

      <asp:GridView ID="GridView3" CellPadding="5" CellSpacing="0"  OnRowDataBound="GridView3_RowDataBound"
                    ForeColor="#333"          runat="server">
                    <HeaderStyle BackColor="#989898" ForeColor="white" />
                </asp:GridView>

           <asp:Button ID="btnupdate" runat="server" Text="Save" OnClick="btnupdate_Click" />
Posted
Updated 11-Sep-19 22:26pm
v2

1 solution

This is a repost of this: Draganddrop unable to change the order of gridview row using C#[^]
Either you are posting the same question - and code fragments - under two users, or your class is all trying to solve the same problem in identical code.

Either way it's a waste of our time to have it in two places, and / or of your time if it's the same class assignment (given that two identical answers will be noticed by your tutor, trust me).
 
Share this answer
 
Comments
Member 14576724 12-Sep-19 5:23am    
Your this answer is also waste ouur time and your's also.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900