Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.Net MVC3 Dropdownlist and passing data
    primarykey
    data
    text
    <p>I have this Controller </p> <pre><code> public ActionResult Index() { IList&lt;Partner&gt; p = r.ListPartners(); ViewBag.Partners = new SelectList(p.AsEnumerable(), "PartnerID", "Name"); return View(); } // // POST: /Epub/ [HttpPost] public ActionResult Index(IEnumerable&lt;HttpPostedFileBase&gt; fileUpload) { IList&lt;Partner&gt; p = r.ListPartners(); ViewBag.Partners = new SelectList(p.AsEnumerable(), "PartnerID", "Name"); int count = 0; for (int i = 0; i &lt; fileUpload.Count(); i++) { if (fileUpload.ElementAt(i) != null) { count++; var file = fileUpload.ElementAt(i); if (file.ContentLength &gt; 0) { var fileName = Path.GetFileName(file.FileName); // need to modify this for saving the files to the server var path = Path.Combine(Server.MapPath("/App_Data/uploads"), Guid.NewGuid() + "-" + fileName); file.SaveAs(path); } } } if (count == 0) { ModelState.AddModelError("", "You must upload at least one file!"); } return View(); } </code></pre> <p>And the corresponding view </p> <pre><code> @{ ViewBag.Title = "Index"; } &lt;h2&gt;You are in the epub portal!&lt;/h2&gt; @Html.Partial("_Download") @model IEnumerable&lt;EpubsLibrary.Models.Partner&gt; @{ @Html.DropDownList("PartnerID", (IEnumerable&lt;SelectListItem&gt;)ViewBag.Partners) } </code></pre> <p>I am trying to figure out how to pass the selected PartnerID from the view back to the controller. Any pointers would be appreciated. I have looked at other posts but cannot seem to locate a solution that will help with this. </p> <p>Thanks in advance for your time. </p>
    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.
 

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