Asp.net mvc 3 如何将字典集合从模型绑定到razor视图中的下拉列表?
请找到我的blow代码,建议如何在下拉菜单中绑定收藏列表 控制器Asp.net mvc 3 如何将字典集合从模型绑定到razor视图中的下拉列表?,asp.net-mvc-3,asp.net-mvc-4,Asp.net Mvc 3,Asp.net Mvc 4,请找到我的blow代码,建议如何在下拉菜单中绑定收藏列表 控制器 Public ActionResult Registation() { RegisrationModel register=new RegisterationModel(); register.Country=GetContryCode(); view(register); } 型号: public class RegistrationModel{ Dictionary<int,string> Country=new
Public ActionResult Registation()
{
RegisrationModel register=new RegisterationModel();
register.Country=GetContryCode();
view(register);
}
型号:
public class RegistrationModel{
Dictionary<int,string> Country=new Dictionary<int,string>();
public Dictionaly<int,string> GetCountryCode()
{
County.Add(1,"India");
Country.Add(2,"Us");
so on.
}
}
公共类注册模型{
字典国家=新字典();
公共词汇GetCountryCode()
{
添加(1,“印度”);
国家。添加(2,“美国”);
等等。
}
}
RazorView:registration.cshtml->您能建议如何在Razor视图中绑定Country属性吗?我想以前有人问过这个问题:非常感谢您的信息。