Reputation:
Here I create a simple ArrayList. How can I display all the names in <ul> <li>
in Viewpage
public ActionResult ArrayList()
{
ArrayList list = new ArrayList();
list.Add(12);
list.Add("Ghouse");
list.Add(12.258);
foreach(var xx in list)
{
ViewBag.ArrayList = xx;
}
return View();
}
Upvotes: 0
Views: 3863
Reputation: 1635
You add arrayList to Viewbag:
ViewBag.data = list;
Then display the Viewbag in View :
foreach (var list in ViewBag.data)
{
<li>@list</li>
}
Upvotes: 3