C# 不是我的日常语言,所以对它很陌生
这是我的模特
public class SpecialtyListsModels
{
public Dictionary<int, dynamic> specialties = new Dictionary<int, dynamic>();
public Dictionary<int, dynamic> SpecialtyLists()
{
specialties.Add(1, new {name = "Varun", age = "11"} );
specialties.Add(2, new {name = "Khushi", age = "12"} );
return (specialties);
}
}
这是我的课
public class SignupController : Controller
{
public ActionResult Index()
{
PFSignup.Models.SpecialtyListsModels objSpecialtyList = new PFSignup.Models.SpecialtyListsModels();
Dictionary<int, dynamic> specialtyLists = objSpecialtyList.SpecialtyLists();
return View();
}
[HttpPost]
public ActionResult Create(SignupModels signup)
{
return View(signup);
}
}
这是我的视图,我想在其中添加所有专业的下拉列表
<body>
<div>
@using (Html.BeginForm("Create", "Signup"))
{
<label for="first_name">First Name:</label>
<input type="text" name="first_name" id="first_name" value="" />
<br />
<label for="last_name">Last Name:</label>
<input type="text" name="last_name" id="last_name" value ="" />
@Html.DropDownList("specialty_list", new SelectList(SpecialtyListModels, )
<input type="submit" name="submit" value="Submit" />
}
</div>
有人可以帮我解决下拉列表代码吗,我需要在视图顶部添加列表吗?