를 추가 내가보기에서 사용하는 경우 나는 다음과 같은 부분보기 내가 예를 들어 EditorTemplate 내부에 그것을 사용하는 경우 드롭 다운리스트 이름은 수정되지 않은 남아 있지만Html.DropDownList가 자동으로 접두사
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcMusicStore.Models.Product>" %>
<span class="price">Precio: <em><strong><%: Html.Price(Model) %></strong></em></span>
<div class="wrapper">
<% if (Model.Active) { %>
<% using (Html.BeginForm("AddToCart", "ShoppingCart", new { id = Model.ProductId }, FormMethod.Post, new { id = "addtocart-form" })) {%>
<% if (Model.MetricType == (int)ProductMetricType.Units) { %>
<%: Html.DropDownList("Quantity" , new SelectList(DropDownLists.Units , "Value", "Key" , Model.MetricType)) %>
<% } else { %>
<%: Html.DropDownList("Quantity", new SelectList(DropDownLists.Kilograms, "Value", "Key", Model.MetricType)) %>
<% } %>
<input type="submit" value="Comprar" />
<% } %>
<% } else { %>
<span class ="buttonBig">Sin existencias!</span>
<% } %>
</div>
을 BuyProduct.ascx 한 :
<%@ Import Namespace="MvcMusicStore"%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MvcMusicStore.Models.Product>" %>
<li>
<h3><%: Html.Truncate(Model.Name, 25) %></h3>
<p><a href="<%: Url.Action("Details", "Store", new { id = Model.ProductId }) %>"><img alt="<%: Model.Name %>" src="<%: Model.ProductArtUrl %>" width="180" height="165" /></a></p>
<% Html.RenderPartial("BuyProduct", Model); %>
</li>
내 컨트롤러 코드 :
public ActionResult AddToCart(Guid id, int quantity = 1) {
미주리의 이름의 접두사 del 클래스가 DropDownList 이름 (Product.Quantity 삽입 수량)에 추가되고 더 이상 올바른 값을 얻지 못합니다. 두 가지 경우 모두 해결하는 방법에 대한 아이디어가 있습니까?