2
我无法获取mvc下拉列表中的选定项目。我受不了viewdata,每个例子都使用它。这是我的代码,预先感谢。在asp.net上获取选定的值mvc selectlist
//controller
public ActionResult Register(Models.Person APerson)
{
}
public class Person
{
public Person()
{
using (var model = new theModel())
{
var countriesList = (from c in model.Countries
orderby c.Name ascending
select c).ToList();
Countries = new SelectList(countriesList, "ID", "Name");
}
}
[Required]
[DisplayName("Country")]
public SelectList Countries { get; set; }
public string SelectedCountry { get; set; }
}
<%=Html.DropDownListFor(m => m.SelectedCountry, Model.Countries) %>
我知道这里有一堆Q,但我找不到一个使用该模式的简单示例。
那么很简单,你是对的,谢谢。我认为这将在各国。选定的价值......欢呼声。 – user376456 2010-09-14 20:54:28
如果你在视觉工作室编码...“intellisense”是你的朋友。 – Scott 2010-09-14 20:58:04