I have a list of cities and a list of countries and both of them I want to have on the view (aspx) file. I'm trying something like this but it's not working:
namespace World.Controllers { public class WorldController : Controller { public ActionResult Index() {
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>