I have maanged to get a ReorderList working if I drag an item from top to bottom. However if I drag an item from bottom to top it does not work.
Below the markup I use
this is the SqlDataSource code markup and I am not sure if I do need the update event here is I also use the ReorderList1_It emReorder event in my code behind
below my code behind
Below the markup I use
Code:
<div class="form" id="DivActions" runat="server">
<asp:ReorderList ID="ReorderList1" runat="server" CssClass="reorderList"
AllowReorder="True"
DataKeyField="Publication_ID"
SortOrderField="Order_On_Page"
PostBackOnReorder="true"
CallbackCssStyle="callbackStyle"
DragHandleAlignment="left"
DataSourceID="SqlDS_Pubs" >
<ItemTemplate>
<table class="table-reorder">
<tr>
<th>Title</th>
<th>Page Order</th>
</tr>
<tr>
<td><%# Eval("Title")%></td>
<td class="reordercenter"><%# eval("Order_On_Page") %></td>
</tr>
</table>
</ItemTemplate>
<DragHandleTemplate>
<div class="DivDrag">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/icons/drag_handle.png" />
</div>
</DragHandleTemplate>
</asp:ReorderList>
</div><!-- end DivActions -->
Code:
<asp:SqlDataSource ID="SqlDS_Pubs" runat="server" ConnectionString="<%$ ConnectionStrings:ConnString %>"
SelectCommand="usp_Publications_Select" SelectCommandType="StoredProcedure"
UpdateCommand="usp_Publications_Change_Order"
UpdateCommandType="StoredProcedure" >
<SelectParameters>
<asp:Parameter Direction="Output" Name="Message" Type="String" size="1000" />
<asp:Parameter Direction="Output" Name="RetVal" Type="Int16" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Publication_ID" Type="Int32" />
<asp:Parameter Name="Order_On_Page" Type="Int32" />
<asp:Parameter Direction="Output" Name="Message" Type="String" size="1000" />
<asp:Parameter Direction="Output" Name="RetVal" Type="Int16" />
</UpdateParameters>
</asp:SqlDataSource>
Code:
Protected Sub ReorderList1_ItemReorder(ByVal sender As Object, ByVal e As
AjaxControlToolkit.ReorderListItemReorderEventArgs) Handles ReorderList1.ItemReorder
Try
'get Old Priority
Dim SelectedItemOldOrder As Integer = e.OldIndex
'get New Priority
Dim SelectedItemNewOrder As Integer = e.NewIndex + 1
'get the selected Item Value
Dim selectedDK As String = ReorderList1.DataKeys(SelectedItemOldOrder).ToString()
Dim i2updateList As String = ""
'Build update list based on everything after/equal to the new priority but not equal to the selected one and in order so they can be updated in order
Dim DsPubs As DataSet = Nothing
DsPubs = Pubs.GetRecordByIDForOrdering(selectedDK)
If Not IsNothing(DsPubs) Then
If DsPubs.Tables.Count > 0 Then
If DsPubs.Tables(0).Rows.Count > 0 Then
For Each R As DataRow In DsPubs.Tables(0).Rows
Dim OrderOnPage As String = 0
OrderOnPage = R.Item("Publication_ID").ToString()
If String.IsNullOrEmpty(i2updateList) Then
i2updateList = OrderOnPage
Else
i2updateList += "," & OrderOnPage
End If
Next
End If
End If
End Sub