user7360479
user7360479

Reputation:

How to Display ArrayList in in view

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

Answers (1)

Rai Vu
Rai Vu

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

Related Questions