<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ReorderList ID="ReorderList1" runat="server"
onitemreorder="ReorderList1_ItemReorder">
<DragHandleTemplate>
<div style="width:30px; height:25px; cursor:move" />
</DragHandleTemplate>
<ReorderTemplate>
<div style="width:100%; height:25px; border:dashed thin black;" />
</ReorderTemplate>
<ItemTemplate>
<asp:Label ID="ItemLabel" runat="server" Text=‘<%#Eval("description") %>‘ />
</ItemTemplate>
</asp:ReorderList>
</ContentTemplate>
</asp:UpdatePanel>
protected void ReorderList1_ItemReorder(object sender, AjaxControlToolkit.ReorderListItemReorderEventArgs e)
{
string strCnn = "Server=10.16.33.20;Database=MyRoleTest;User ID=sa;Password=123456;Pooling=true; MAX Pool Size=512;Min Pool Size=5;Connection Lifetime=30 ";
SqlConnection conn = new SqlConnection(strCnn);
//string sql = "update ajax set position=‘" + e.NewIndex + "‘ where position=‘" + e.OldIndex + "‘";
string sql = "";
sql = " update AJAX set position=-999 where position=" + e.OldIndex +";";
if (e.NewIndex > e.OldIndex)
{
sql = sql + " update AJAX set position=position-1 where position>" + e.OldIndex + " and position<=" + e.NewIndex + "; ";
}
else if (e.NewIndex < e.OldIndex)
{
sql = sql + " update AJAX set position=position+1 where position>=" + e.NewIndex + " and position<" + e.OldIndex + "; ";
}
//sql = sql + " update AJAX set position=" + e.NewIndex + " where position=" + e.OldIndex + " ;";
sql = sql + " update AJAX set position=" + e.NewIndex + " where position=-999 ;";
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Dispose();
//NewMethod();
}