O'Reilly logo

Bootstrap for ASP.NET MVC by Pieter van der Westhuizen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading and displaying data in jQuery DataTables

In order to implement the jQuery DataTables plugin, we first need to create a new view that will list data inside an HTML table. For this example, we'll create a view that lists customers from the Northwind Traders database. For this, complete the following steps:

  1. In Visual Studio, add a new controller class called CustomersController.cs.
  2. We've implemented a dependency injection in our project, so we'll add a constructor to the class that will automatically set the reference to the database context with the following code:
    public CustomersController(ApplicationDbContext context)
    {
        _context = context;
    }
  3. The _context object is a local field declared inside the class as follows:
    private readonly ApplicationDbContext ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required