ASP. Repeater drag and drop to sort and synchronize sort fields into the database

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.