码迷,mamicode.com
首页 > 其他好文 > 详细

ReorderList 的使用

时间:2014-12-16 18:37:15      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:des   style   ar   io   os   使用   sp   on   div   

  <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();
        }

 

ReorderList 的使用

标签:des   style   ar   io   os   使用   sp   on   div   

原文地址:http://www.cnblogs.com/movemoon/p/4167542.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!