Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way to do it is to populate your address list in your controller and use the Html.DropDownList helper to create your drop down.</p> <p>For example:</p> <pre><code>public ActionResult Index() { var addressList = &lt;YourAddressListHere&gt;; ViewData["Addresses"] = new SelectList(addressList, "&lt;ValueProperty&gt;", "&lt;NameProperty&gt;"); return View(); } </code></pre> <p>And in your view (Razor syntax):</p> <pre><code>@Html.DropDownList("AddressDropDown", (ViewData["Addresses"] as SelectList)) </code></pre> <p>There is also Html.ListBoxFor and Html.ListBox helpers if you wanted to do multi-select. The same basic approach applies.</p> <hr> <p>(EDIT) Sorry for my misunderstanding.</p> <p>To get the list of addresses that were selected you can add the control name as a parameter in you "POST" handler and extract them during the save/edit/insert function.</p> <pre><code>[HttpPost] public ActionResult Edit(int[] addressList, &lt;your parameters&gt;) ..... </code></pre> <p>with the UI code as:</p> <pre><code>&lt;div class="editor-field"&gt; @Html.ListBox("addressList") &lt;/div&gt; </code></pre> <p>You can do whatever you need with the list of address ID's that were selected. I know that there is more than likely a better way to do this with MVC. If anyone looks at this and knows a better way, please comment because I'd like to know myself. I know that you can create some custom binder classes that I think will do all of this stuff automatically, but I haven't gotten that far yet with MVC. I, myself, am a beginner with MVC. </p> <p>In any case, I hope this helps a bit.</p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload