Link to home
Start Free TrialLog in
Avatar of someonenamedbrendan
someonenamedbrendan

asked on

asp.net drag and drop gridview

Hi,

I found an example of a gridview that I can reorder via drag and drop. The user drags the row to a second gridview and it keeps the new order.

 <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js" type="text/javascript"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script>
<link rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />
<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();
    });
</script>

 <asp:GridView ID="gvSource" runat="server" CssClass="drag_drop_grid GridSrc" AutoGenerateColumns="false">
    <Columns>
     <asp:BoundField DataField="PID" HeaderText="VoteID"/>
     <asp:BoundField DataField="CustID" HeaderText="CustID"/>
     <asp:BoundField DataField="FeatureID" HeaderText="FeatureID"/>
     <asp:BoundField DataField="DESC" HeaderText="ShortDESC"/>
    </Columns>
</asp:GridView>

 <asp:GridView ID="gvDest" runat="server" CssClass="drag_drop_grid GridSrc" AutoGenerateColumns="false">
    <Columns>
     <asp:BoundField DataField="PID" HeaderText="VoteID"/>
     <asp:BoundField DataField="CustID" HeaderText="CustID"/>
     <asp:BoundField DataField="FeatureID" HeaderText="FeatureID"/>
     <asp:BoundField DataField="DESC" HeaderText="ShortDESC"/>

    </Columns>
</asp:GridView>


        For Each row As GridViewRow In gvDest.Rows

    
            Dim PID As String = row.Cells(0).Text
            Dim custID As String = row.Cells(1).Text
            Dim featureID As String = row.Cells(2).Text
            Dim DESC As String = row.Cells(3).Text
            Dim position As String = row.Cells(4).Text

        Next

Open in new window


The problem is, my code doesn't see the new order. Just the original order even though it's changed on the screen.

I need to be pointed in the right direction.


Thanks for any help.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of someonenamedbrendan
someonenamedbrendan

ASKER

I've requested that this question be deleted for the following reason:

did it completely another way.
which way? does that mean my solution is not right?