现在的位置: 首页 > 数据库 > 正文

ReorderList数据源绑定(拖动更新数据库) (经本人测试,无法拖动!!)

2019年03月25日 数据库 ⁄ 共 2327字 ⁄ 字号 评论关闭
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.RLCss
{
line-height:30px;
}
.RLCss ul li
{
list-style-type:none;
}
.DivDragCss
{
width:800px; 
border:solid #CCCCCC 1px;
cursor:move; 
margin-right:10px;
height:25px;
padding-left:10px;
padding-bottom:10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager runat="server"></asp:scriptmanager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:ReorderList ID="ReorderList1" Width="100%" runat="server" AllowReorder="True" DataSourceID="SqlDataSource1"
PostBackOnReorder="true" DataKeyField="id" SortOrderField="orderBy" ItemInsertLocation="Beginning" 
DragHandleAlignment="Left" ShowInsertItem="true" CssClass="RLCss">
<ItemTemplate>
</ItemTemplate>
<EmptyListTemplate>
Sorry!No resource to display!
</EmptyListTemplate>
<DragHandleTemplate>
<div class="DivDragCss">
<table width="800px;"><tr><td><%# Eval("showConent")%></td><Td style="width:30px; text-align:right;"><%# Eval("id")%></Td></tr></table>
</div>
</DragHandleTemplate>
<ReorderTemplate>
<asp:Panel ID="panReorderTmp" runat="server">
<div style="width:800px; border:dashed red 1px;cursor:pointer;">   </div>
</asp:Panel>
</ReorderTemplate>
</cc1:ReorderList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT * FROM [ReorderList] ORDER BY orderBy" OldValuesParameterFormatString="original_{0}"
UpdateCommand="UPDATE [ReorderList] SET orderBy = @orderBy WHERE ID=@ID " ConflictDetection="CompareAllValues">
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ReorderList1" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

 

数据库表
CREATE TABLE [dbo].[ReorderList] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[showConent] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
[orderBy] [int] NULL
) ON [PRIMARY]
自己增上几条记录试试看呀!

抱歉!评论已关闭.