im using the sortable jquery plugin, because i want that the user can choice the order of the images are showing in my view.
For this i have a Get Controller which sends the data to my PartialView.
How can i make the now the Post Controller to update my table in my database?
Note: In this moment the controller don´t receive any data. i haven´t figured out what is wrong
Someone can help me with this?
Thanks in advance:
Here is my code:
In My PartialView:
@(Html.BeginForm("UpdateOrder", "Admin", FormMethod.Post)){
<div id="Order">
<ul id="sortable">
@foreach (var p in ViewBag.Images)
{
<li id="@Html.AttributeEncode(p.FileName)">
<img src="~/Files/@p.FileName"/>
</li>
}
</ul>
</div>
}
Controller:
if (ModelState.IsValid)
{
using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
{
SqlCommand cmd;
System.Text.StringBuilder sql = new System.Text.StringBuilder();
sql.Append("Update Image Set MyFileName=??? Order By ASC");
cn.Open();
cmd = new SqlCommand(sql.ToString(), cn);
cmd.Parameters.Add(??????????).Value = ;
cmd.ExecuteNonQuery();
cn.Close();
}
}
return View();