我需要创建数字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");
}
我如何在“SecondView”中显示数字?
答案 0 :(得分:1)
@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" } )