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

时间: 2024-11-08 21:30:26

ReorderList 的使用的相关文章

reorder-list——链表、快慢指针、逆转链表、链表合并

Given a singly linked list L: L0→L1→-→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→- You must do this in-place without altering the nodes' values. For example,Given{1,2,3,4}, reorder it to{1,4,2,3}. 由于链表尾端不干净,导致fast->next!=NULL&&fast->next-&

reorderList使用

<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" /> <form id="form1" runat="server"><ajaxToolkit:ToolkitScriptManager ID="asm" runat="server">    </aja

[LeetCode]Reorder List

Given a singly linked list L: L0→L1→-→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→- You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorder it to {1,4,2,3}. 这道题是将一个给定的单链表按照某种规则进行重排序,要求是不可以简单地直接交换结点中的值. 思路

leetcode笔记

leetcode 笔记 Linked List 2. Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a

143. Reorder List

本周对链表操作进行了巩固 题目: Given a singly linked list L: L0→L1→-→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→- You must do this in-place without altering the nodes' values. For example,Given {1,2,3,4}, reorder it to {1,4,2,3}. 题解: 这道题虽然看上去很复杂,但经过分析,可知实质上这道题就是

Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given {1,2,3,4}, reorder it to {1,4,2,3}. 这是一道比较综合的链表题目.一开始拿到手足无措.慢慢分析了一下,其实做法无非分三步: 1.将链表分

leetcode143 Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given {1,2,3,4}, reorder it to {1,4,2,3}. 1 /** 2 * Definition for singly-linked list. 3 *

leetcode-143. Reorder List

刚开始刷题,一开始没思路,上网看了一下别人的思路才写出来 总的思路就是先把链表分为两部分,可以先遍历链表再根据长度分也可以用快慢指针(新知识点),然后将第二部分反转,再依次插入到第一部分.思路很简单,但没用ide还是出错了... /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }

[Linked List]Reorder List

otal Accepted: 54991 Total Submissions: 252600 Difficulty: Medium Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given {1,2,3,4}, reorder