2

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()
   }

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.