How to sort listbox items and save this sorting in database RRS feed

  • Question

  • now this is the code in .aspx file
                    <center><asp:DataList ID="DataList1" runat="server" RepeatColumns="5" CellPadding="4" CellSpacing="10"  OnItemCommand="DataList1_ItemCommand">
                        <table width="90%">
                                   <asp:ImageButton ID="ImageButton1" CommandArgument='<%#Eval("D_NAME") %>' runat="server" Height="300px" Width="250px" ImageUrl='<%#Eval("D_IMAGE") %>' CommandName="viewdetail" /> <br /></td>
                                <td><br /></td>

    and this s the code in .cs file
     SqlCommand cmd = new SqlCommand();
                SqlConnection con = new SqlConnection();
                SqlDataReader sdr;
                DataSet d = new DataSet();
               // string[] dno, dimage;
                int i = 0;
                protected void Page_Load(object sender, EventArgs e)
                    if (Session["user_id"] == null)
                        if (!IsPostBack)
                            con.ConnectionString = "Data Source=SHAHZAIB;Initial Catalog=CHILDREN_ISLAM;Integrated Security=True";
                            string q = "select * from DUAS inner join Selected_List on DUAS.DNO=Selected_List.DNO where Selected_List.U_ID='"+ Session["user_id"] + "'";
                            //cmd = new SqlCommand(q, con);
                            //sdr = cmd.ExecuteReader();
                            SqlDataAdapter sda = new SqlDataAdapter(q, con);
                            DataTable dt = new DataTable();
                            DataList1.DataSource = dt;
                            // dno[i] = sdr["DNO"].ToString();
                            //dimage[i] = sdr["D_IMAGE"].ToString();
                            //daudio[i] = sdr["D_AUDIO"].ToString();
                            //CheckBoxList2.DataValueField = "DNO";
                            ////CheckBoxList1.DataValueField = "D_IMAGE";
                            //CheckBoxList2.DataTextField = "D_IMAGE";
                            //// CheckBoxList1.DataValueField = "D_AUDIO";
                            ////DataTable dt = new DataTable();
                            ////string[] a = { "a", "b", "c" };
                            //CheckBoxList2.DataSource = sdr;
                    catch (Exception ex)
                protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
                    string DNO = e.CommandArgument.ToString();
                    Response.Redirect("duacontainer.aspx?e=" + DNO);

    what i simply want to do is to drag one of the listbox item which is being displayed and if i place it on another listbox it should be replaced with that and this sorting should be saved in database as soon as its replaced
    i know i can use jquery draggable or sortable but i don't know how to store it in database so that when user logs in again he get to see the sorting he did last time
    • Moved by CoolDadTx Friday, July 31, 2020 1:45 PM ASP.NET related
    Friday, July 31, 2020 10:52 AM

All replies

  • Hello,

    Here is the forum for ASP.NET questions https://forums.asp.net/

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Friday, July 31, 2020 11:16 AM