Get selected DropDownList item from MVC Partial view

I use @Html.DropDownList in a partial view for show the list of banks and render it in the Bank Branch view. How can i get the selected Bank in @Html.DropDownList and fill the BankId in the BankBranchModel .

here is my code:

BankBranchModel :

public class BankBranchModel : BaseModel
    public int? **BankID** { get; set; }
    public string Name { get; set; }
    public string Code { get; set; }
    public string Phone { get; set; }
    public string Address { get; set; }

My partial view :

@Html.DropDownList("Banks", Model , "- Please Select -"})

BankBranch View:

@model MvcFirstSample.Models.BankBranchModel
    ViewBag.Title = "create";


@using (Html.BeginForm())

    <div class="editor-field">
        **@Html.Action("GetAllBank", "BankBranch")**


GetAllBanks for return the Partial view:

public ActionResult GetAllBank()

            var Banks = Context.Banks.ToList();
            List<BankLookup> BankLookupList = new List<BankLookup>();

            var listItems = new List<SelectListItem>();

            foreach (var Bank in Banks)
                listItems.Add(new SelectListItem { Text = Bank.Name, Value = Bank.Id.ToString()});

            **return PartialView("BankLookup", listItems);**

How to get previous selected item and current selected item from dropdownlist using Javascript?

How to get previous selected item and current selected item from dropdownlist using Javascript?I think, use couple of hidden fields and store previous and current value in them. When the dropdownlist

Get selected item in dropdownlist MVC 4 Razor

I know there are multiple threads on how to get the selected value of a dropdownlist. However i can’t find the right way to get this value from a partial view in my controller. This is my partial view

Get posted selected item from DropDownList in ASP MVC

Controller public ActionResult Create() { return View(new PageViewModel()); } [HttpPost] public ActionResult Create(Page page) { try { repPage.Add(page); repPage.Save(); return RedirectToAction(Edit

Dynamically Changing View from selected dropdownlist item from Model Data in MVC

I’m not sure I have my head wrapped around this problem right, so bear with me if the explanation seems lacking. I’m still somewhat new at MVC-3. I have an MVC page that I’m not certain what the best

MVC4 – Setting Initially Selected Item in DropDownList

I am passing in a list of objects to my View via a model @model MyModel.ObjectViewModel I am new to MVC and am trying to set the initially selected item of a dropdownlist in my view (modelled after a

How to get the selected value from dropdownlist in Controller (MVC 2)

I am struggling to get the selected value from the hard-coded dropdownlist in mvc , below is the code: View: <tr><td>No of Helmets</td><td><div class=editor-field> <

asp mvc DropDownList how to pass a selected item in visual basic .net

asp mvc DropDownList how to pass a selected item in visual basic .net i put this in the view: <%=Html.DropDownList(Estados, ViewData(EstadosList))%> and the compiler says that i have to conv

mvc dropdownlist selected item issue

Good evening everybody I have a question about dropdown selected item. I have a data on my database and I am selecting and showing them in my grid. However when I want them to edit the dropdown field

Get Data From MVC partial view

I defined a view for my master model and call the detail partial view in it.My master model contain a list .How can I get data from my partial view when page post back to the server? Here is my code :

How to pass multiple Html.DropDownList selected values from View( .aspx ) to MVC controller’s action?

I need to pass multiple data ( probably 2 Html.DropDownList’s selected values ) to MVC controller action method from MVC View ( .aspx). I think it would be from somehow Html.Hidden form , but how? I a


Here is one way…

In your Partial View:


In your controller, populate the list by binding ids and values:

ViewBag.bank_list = new SelectList(listItems, "Text", "Value");

Why you don’t want to use ViewBag? In your Partial View you can say:

@Html.DropDownList("listItems",(IEnumerable<SelectListItem>)ViewBag.listItems )

, then use Jquery to get selected item:

      var selectBanks= $("#listItems");

        var selectedOptionId = selectBanks.find("option:selected").val();

Then populate input for bankid assuming it has id of bankid: