database table has a unit table, which includes the ID, Name, order and other fields, there is now a background management function, you can set these units in some statistical tables in the order of sequential display, and then think of a drag-and-drop way to achieve, so easier to operate.
A sample animation was made using the Gifcam software, as shown in the following:
So I started, found Jquery.ui in the sortable function, can be used to sort, the interface from the database binding units using Repeater control, the following is a brief introduction to the following main steps:
1, jquery-1.7.2.min.js and jquery-ui.min.js used in the project, please click to download, the address is: http://download.csdn.net/detail/ taomanman/9315373
2. The testdemo.aspx code is as follows:
<! DOCTYPE html>TestDemo.cs code as follows, the specific database operation class to obtain data according to their own situation, here is not detailed introduction.
public partial class TestDemo:System.Web.UI.Page {public static GGJ_DC_DATACENTERBASEINFOBLL BLL = new Ggj_dc_ DATACENTERBASEINFOBLL (); protected void Page_Load (object sender, EventArgs e) { if (! IsPostBack) { binddata (); } } <summary> ///Binding Ministries Units ///</summary> public void Binddata () { string where = ' "; String = "F_order ASC"; DataTable dt = BLL. GetData (where, by-and-by); This.rpt.DataSource = DT; This.rpt.DataBind (); } }
3, $.ajax method request page update.aspx and Update.aspx.cs code as follows:
<! DOCTYPE html> Public partial class Update:System.Web.UI.Page {public static GGJ_DC_DATACENTERBASEINFOBLL BLL = new Ggj_ DC_DATACENTERBASEINFOBLL (); protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {String order = request["Order"]. ToString (); String depid = request["id"]. ToString (); UpdateOrder (depid, order); }}///<summary>//re-update order///</summary>//<param name= "DeptID" > </param>//<param name= "order" ></param> public void UpdateOrder (String deptid, String or der) {string[] Deptids = Deptid.split (', '); string[] orders = order. Split (', '); for (int i = 0, i < deptids.length; i++) {for (int j = 0; j < orders. Length; J + +) {if (i = = j) {String sql = "Update ggj_dc_datacenterbaseinfo set f_order=" + orders[j] + "where f_datacenterid= '" + deptids[i]+ "'"; DataTable dt = CommonClass.QuerySQL.GetDataTable (SQL); if (dt. Rows.Count > 0) {}}}} } }
ASP. Repeater drag and drop to sort and synchronize sort fields into the database