Tutorial :ASP.Net-MVC sample code to retrieve selected item from html dropdownlist



Question:

Can somebody give me an sample code to retreive the item from html.dropdownlist?


Solution:1

Suppose that you have this DropDown in the view:

<p><label for="ProductType">Product Type:</label>  <br /><%=Html.DropDownList("ProductTypeDropDown",                New SelectList(ViewData("ProductTypes"),                "ProductTypeID", "Name"))%>  </p>  

You can simple retrieve the selected value in the controller using

Product.ProductType = form("ProductTypeDropDown")  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »