【发布时间】:2009-01-20 23:57:53
【问题描述】:
我有一个城市列表和一个国家列表,我希望在视图 (aspx) 文件中包含这两个列表。我正在尝试这样的事情,但它不起作用:
命名空间 World.Controllers { 公共类世界控制器:控制器{ 公共动作结果索引(){
List<Country> countryList = new List<Country>();
List<City> cityList = new List<City>();
this.ViewData["CountryList"] = countryList;
this.ViewData["CityList"] = cityList;
this.ViewData["Title"] = "World Contest!";
return this.View();
}
}
}
<table>
<% foreach (Country country in this.ViewData.Model as IEnumerable) { %>
<tr>
<td><%= country.Code %></td>
</tr>
<% } %>
</table>
【问题讨论】:
标签: asp.net-mvc