2016-09-18 37 views
0

我想将从DropDownlist中选择的一个数字传递给其他控制器中的GET Create方法。它看起来像:DropDownList不通过附加参数

[HttpGet] 
public ActionResult Details(int? id, string error) 
    { 
     {...} 
     var numbers = Enumerable.Range(1, 100); 
     ViewBag.Quantity = numbers.Select(i => new SelectListItem { Value = i.ToString(), Text = i + "%" }); 
     return View(viewModel); 
    } 

public ActionResult Create(int ID, int quantity) 
     { 
      {...} 
     } 

详细信息视图的样子:

<div> 
    @if (Model.ItemRent.Zatwierdzony == false) 
    { 
     using (Html.BeginForm("Create", "ItemRentLists", new { ID = @Model.ItemRent.ItemRentID }, FormMethod.Get)) 
     { 
      @Html.DropDownList("quantity", new SelectList(ViewBag.Quantity, "Text", "Value")) 
      <input type="submit" value="Dodaj przedmioty"/> 
     } 
    } 
</div> 

DropDownList的不传值“量”参数创建方法,这里有什么问题?

回答

0

好的,我改变了@Html.DropDownList("quantity", ViewBag.Quantity as SelectList),现在它工作,因为它应该工作。