Sachin Yadav
Sachin Yadav

Reputation: 187

Table show in List in MVC 4

 public class PersonsController : Controller
{
    //
    // GET: /Persons/
    PersonContext PC = new PersonContext();
    public ActionResult Index()
    {
        List<Person> P = PC.person.ToList();

        return View(P);
    }
    public ActionResult Edit()
    {

        return View();
    }
}

This is my controller class and I want to display my table data in List Format. How can I do this?

MY model class is Person and Context class is PersonContext.

Upvotes: 0

Views: 43

Answers (1)

Solomiia Kalinchuk
Solomiia Kalinchuk

Reputation: 193

It depends what properties you have in your 'Person' model. But you can use such sample in your view:

<ul>
    @foreach (var person in Model)
    {
      <li>paste here primitives of your `Person` model</li>
    }
</ul>

Upvotes: 1

Related Questions