Rather create the Model for the country, and return that model to view.
// Model
public class Country
{
public int ID { get; set; }
public string Name { get; set; }
}
// Controller
public ActionResult Index()
{
List<country> countries = new List<country>() {
new Country() { ID = 1, Name = "India"},
new Country() { ID = 2, Name = "Pakistan"},
new Country() { ID = 3, Name = "Australia"},
new Country() { ID = 4, Name = "South Africa"}
}
return View(countries);
}</country></country>
// View
@model IEnumerable<country>
<ul>
@foreach(var item in Model)
{
<li id="@item.ID">@item.Name</li>
}
</ul></country>
This is the basic idea how you can do it in MVC, you can change this according to your need. :)
[Updates after the comments]
// controller
IEnumerable<string> list = new List<string><br />
{<br />
"INDIA",<br />
"PAKISTHAN",<br />
"AUSTRALIA",<br />
"SOUTH AFRICA"<br />
};<br />
ViewData["countries"] = list;<br />
<br />
<br />
@foreach (string item in ViewData["countries"] as List<string>)<br />
{<br />
<p>@item</p><br />
}
-KR