and*_*567 2 model-view-controller asp.net-mvc drop-down-menu
我需要创建包含数字 1 到 30 的下拉列表。并将此号码转移到另一个视图,我需要在其中显示它。谢谢
查看(索引)
@Html.BeginForm()
{
//this I need DropdownList with numbers from 1 to 30
<input type = "submit" >Enter/>
}
[HttpPost]
public ActionResult Index()
{
return RedirectToAction("SecondView");
}
Run Code Online (Sandbox Code Playgroud)
如何在“SecondView”中显示数字?
小智 6
@Html.DropDownListFor(m => m.WorkExperienceTime, Enumerable.Range(1, 30).Select(i => new SelectListItem { Text = i.ToString(), Value = i.ToString() }),new { placeholder= Html.DisplayNameFor(x => x.WorkExperienceTime), @class = "form-control" } )
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5934 次 |
| 最近记录: |