ok i have a record grid with different records
plus i have a dropdown as column as well (which ought to go and just save the value i have selected and come back on 开发者_运维技巧the same stage , i have to send some id as well) . how to achieve this . form is at the movement submitting in my code.
<% using (Ajax.BeginForm("SaveStatus", new AjaxOptions { OnSuccess = "jobStatusChanged" }))
{%>
<%=Html.Hidden("JobFormMain",item.int_JobFormMain) %>
<%: Html.DropDownList("SelectedItem", JobHelper.GetSelectStatus(item.int_JobFormMain) as IEnumerable<SelectListItem>, new { onchange = "this.form.submit();" })%>
<% } %>
public ActionResult SaveStatus(int? page,FormCollection form, int id = 0)
{
return View()
}
I would use jquery to bind to the dropdown's change event, and then post the value to your controller action. You can assign a class to the dropdown to make it easy to select with jquery.
<%= Html.DropDownList("SelectedItem", JobHelper.GetSelectStatus(item.int_JobFormMain) as IEnumerable<SelectListItem>, new { @class = "SelectedItemDropDown" })%>
<script type="text/javascript">
$(document).ready(function()
{
$(".SelectedItemDropDown").change(function()
{
$.post("controller/SaveStatus", { id : $(this).val() });
}
}
</script>
精彩评论