• ReorderList 的使用


      <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="30px; height:25px; cursor:move" />
                    </DragHandleTemplate>
                    <ReorderTemplate>
                      <div style="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();
            }

  • 相关阅读:
    guzzle下载图片(laravel+vue)
    leetcode——131.分割回文串
    leetcode——139.单词拆分
    leetcode——115.不同的子序列
    leetcode——72.编辑距离
    leetcode——87.扰乱字符串
    leetcode——123. 买卖股票的最佳时机 III
    leetcode——132. 分割回文串 II
    leetcode——124. 二叉树中的最大路径和
    leetcode——51.N皇后
  • 原文地址:https://www.cnblogs.com/movemoon/p/4167542.html
Copyright © 2020-2023  润新知