Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:16:37+00:00 2026-06-17T20:16:37+00:00

How can I update a dropdownlist in MVC3. I want to refill it with

  • 0

How can I update a dropdownlist in MVC3. I want to refill it with latest data filled by some other view, but I do not want to postback the view and want to achieve it with jquery.
I have a dropdownlist like:

@Html.DropDownListFor(m => m.Department, Model.Departments)
@Html.ValidationMessageFor(m => m.Departments)
<input type="button" value="Refresh" id="btnrefresh" />

I have written jquery code to call controller’s method:

 $("#btnrefresh").click(function () {
 var ref = '@Url.Action("RefreshDepartments")';
 var model = '@Model.ToJson()';
 var data = { empModel: model };
 $.getJSON(ref, data, function (result) { alert(result.message); });
        return false;
    });

And Here is the controller method:

public ActionResult RefreshDepartments(EmployeeModel empModel)
    {
        empModel.Departments = GetDepartments();
        empModel.Roles = GetRoles();
        return Json(new { message = "Updated successfully"}, JsonRequestBehavior.AllowGet);
    }

How can I update the dropdownlist with latest values on clicking “Refresh” button without any postback?
Is it a good idea to pass the model to the controller and update the model properties? What other ways are possible ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:16:38+00:00Added an answer on June 17, 2026 at 8:16 pm

    It doesn’t look to me like you need the model to be posted to your controller for what you’re doing. In addition, yes, you absolutely can do this with jquery! On a side note, you could also do it with an Ajax.BeginForm() helper method, but lets deal with your jquery example.

    Rather than complexify your jquery with your @Url.Action, you can simply call the path itself.

    $("#btnrefresh").click(function () {
        var ref = 'ControllerName/RefreshDepartments';
        $.each(result, function (index, val) {
            $('#whateverYourRenderedDropdownListHtmlObjectis')
                .append($("<option></option>")
                .attr("value", val.Text)
                .text(val.Text));
        });
    });
    

    Now, for your controller…

    public JsonResult RefreshDepartments()
    {
        return Json(GetDepartments, JsonRequestBehavior.AllowGet);
    }
    
    private SelectList GetDepartments
    {
        var deparments = GetDepartments;
        SelectList list = new SelectList(departments);
        return list;
    }
    

    This is an alternative to returning the model. It allows you to manipulate the raw JSON instead. Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to understand how I can update my GUI with a simple text
I need a document based database where I can update single documents but when
I'm really confused. I want to make a Chrome Extension that can update a
I can display my data in my textbox, dropdownlist after retrieve data from sql
I can't find the controls I want when trying to update my gridview. The
How can update a input hidden inside an UpdatePanel on an AsyncPostBack? The user
I am trying to figure out how I can update my sql query dynamically.
I was wondering how GMail and things like that can update the emails in
I am having trouble figuring out how i can update the background of my
I am very new to Ruby, and was wondering how I can update the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.