zoukankan      html  css  js  c++  java
  • ASP.NET拖拽ListBox和ListView中的Item

    方法:JQueryUI

    ListBox:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>jQuery UI Sortable - Connect lists</title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
        <link rel="stylesheet" href="/resources/demos/style.css">
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script>
            $(function () {
                $("#sortable1, #sortable2").sortable({
                    connectWith: ".connectedSortable"
                }).disableSelection();
            });
        </script>
    </head>
    <body>
    
        <ul id="sortable1" class="connectedSortable" style="overflow: scroll; height: 200px;  150px;">
            <li>Item 1</li>
            <li>Item 2</li>
            <li>Item 3</li>
            <li>Item 4</li>
            <li>Item 5</li>
        </ul>
    
        <ul id="sortable2" class="connectedSortable" style="overflow: scroll; height: 200px;  150px;">
            <li>Item A</li>
            <li>Item B</li>
            <li>Item C</li>
            <li>Item D</li>
            <li>Item E</li>
        </ul>
    
    </body>
    </html>

    ListView:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="How_to_drag_and_drop.WebForm2" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        <script>
            $(function () {
                $("#List1,#List2").sortable({
                    connectWith: ".sortable"
                }).selectable();
            });
        </script>
        <style>
            .list li {
                list-style-type: none
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <table>
                <tr>
                    <td>
                        <asp:ListView ID="ListView1" runat="server">
                            <LayoutTemplate>
                                <ul class="sortable list" draggable="true" id="List1" style="overflow: scroll; empty-cells: hide; height: 200px;  150px; border: solid  1px;">
                                    <asp:PlaceHolder ID="PlaceHolder1" id-="itemPlaceholder" runat="server"></asp:PlaceHolder>
                                </ul>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <li id="li1" runat="server">
                                    <%# Eval("Model")%> <%# Eval("Price")%>
                                    <p>TestTestTest</p>
                                </li>
                            </ItemTemplate>
                        </asp:ListView>
                    </td>
    
                    <td>
                        <ul class="sortable list" draggable="true" id="List2" style="overflow: scroll; height: 200px;  150px; border: solid  1px;">
                        </ul>
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>

    后台代码:

        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Connection String");
            SqlDataAdapter sda = new SqlDataAdapter("select * from Car",con);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            ListView1.DataSource = dt;
            ListView1.DataBind();
        }

  • 相关阅读:
    jquery easy ui 学习 (8)basic treegrid
    jquery easy ui 学习 (7) TreeGrid Actions
    jquery easy ui 学习 (6) basic validatebox
    jquery easy ui 学习 (5) windowlayout
    jquery easy ui 学习 (4) window 打开之后 限制操纵后面元素属性
    提示“应用程序无法启动,因为应用程序的并行配置不正确”不能加载 System.Data.SQLite.dll
    visual studio 添加虚线的快捷键
    VS2010打开项目时,出现“已经在解决方案中打开了具有该名称的项目”问题的解决方案
    visual studio 编译时 出现 Files 的值 乱码
    微信 连接被意外关闭
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/13049942.html
Copyright © 2011-2022 走看看