How to sort listbox items and save this sorting in database

  • Thread starter Thread starter Learner177
  • Start date Start date
L

Learner177

Guest
1612578.jpg

now this is the code in .aspx file

<div>
<center><asp:DataList ID="DataList1" runat="server" RepeatColumns="5" CellPadding="4" CellSpacing="10" OnItemCommand="DataList1_ItemCommand">
<ItemTemplate>
<table width="90%">
<tr>
<td>
<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>
</tr>
</table>
</ItemTemplate>
</asp:DataList></center>
</div>


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)
{
Response.Redirect("login.aspx");
}
try
{
if (!IsPostBack)
{
con.ConnectionString = "Data Source=SHAHZAIB;Initial Catalog=CHILDREN_ISLAM;Integrated Security=True";
con.Open();
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();
sda.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
// dno = sdr["DNO"].ToString();
//dimage = sdr["D_IMAGE"].ToString();
//daudio = sdr["D_AUDIO"].ToString();

//CheckBoxList2.DataValueField = "DNO";
////CheckBoxList1.DataValueField = "D_IMAGE";
//CheckBoxList2.DataTextField = "D_IMAGE";
//// CheckBoxList1.DataValueField = "D_AUDIO";
////DataTable dt = new DataTable();
////sda.Fill(dt);
////string[] a = { "a", "b", "c" };
//CheckBoxList2.DataSource = sdr;
//CheckBoxList2.DataBind();
i++;

}

con.Close();
}
catch (Exception ex)
{

Response.Write(ex.ToString());
}

}



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

Continue reading...
 


Write your reply...
Back
Top