Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 如何将字典集合从模型绑定到razor视图中的下拉列表?_Asp.net Mvc 3_Asp.net Mvc 4 - Fatal编程技术网

Asp.net mvc 3 如何将字典集合从模型绑定到razor视图中的下拉列表?

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

请找到我的blow代码,建议如何在下拉菜单中绑定收藏列表

控制器

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属性吗?

我想以前有人问过这个问题:非常感谢您的信息。