ASP.NET Core  

Displaying Large amounts of Records in ASP.NET Core MVC

When beginners start working with ASP.NET Core MVC, a common question is how to display large amounts of data efficiently. Developers coming from WebForms often search for controls like GridView, Repeater, or UpdatePanel. However, ASP.NET Core MVC follows a modern and performance-focused approach and does not support these controls.

This article explains the correct and accepted ways to display lakhs of records in ASP.NET Core MVC, starting from simple concepts and gradually moving toward advanced, production-level implementations.

Understanding the Core MVC Data Binding Concept

In Core MVC, data is not bound to server controls. Instead, the controller sends data to the view, and the view renders it using HTML and Razor syntax.

The key rule is:

Never load all records at once. Always fetch only the data that the user needs.

This rule applies to all real-time applications such as IPO systems, banking portals, and admin dashboards.

Example Scenario

Assume we have an IPOmaster table with lakhs of records and the following fields:

  • Symbol

  • Category

  • CreatedDate

Our goal is to display this data efficiently in a Core MVC application.

1. HTML Table with Razor – The First Step (Beginner Level)

This is the simplest and most important method to understand.
It replaces GridView and Repeater from WebForms.

The controller fetches only a small number of records using pagination.

Controller example:

public IActionResult IPOmaster(int page = 1)
{
    int pageSize = 20;

    var data = _context.IPOmaster
        .AsNoTracking()
        .OrderByDescending(x => x.CreatedDate)
        .Skip((page - 1) * pageSize)
        .Take(pageSize)
        .ToList();

    return View(data);
}

Why this is important:

  • AsNoTracking() improves performance

  • Skip and Take ensure only required rows are fetched

  • Memory usage stays low

View example:

<table class="table table-bordered">
    <thead>
        <tr>
            <th>Symbol</th>
            <th>Category</th>
            <th>Date</th>
        </tr>
    </thead>
    <tbody>
    @foreach (var item in Model)
    {
        <tr>
            <td>@item.Symbol</td>
            <td>@item.Category</td>
            <td>@item.CreatedDate</td>
        </tr>
    }
    </tbody>
</table>

This approach is mandatory knowledge for every MVC developer.

2. Partial View with AJAX – Beginner-Friendly Replacement for UpdatePanel

Beginners often ask how to update only part of the page without refreshing everything.
In Core MVC, this is done using Partial Views with AJAX.

Partial View (_IPOmasterList.cshtml):

<table class="table table-striped">
@foreach (var item in Model)
{
    <tr>
        <td>@item.Symbol</td>
        <td>@item.Category</td>
        <td>@item.CreatedDate</td>
    </tr>
}
</table>

Controller:

public IActionResult IPOmasterList(int page = 1)
{
    var data = GetPagedIPOData(page);
    return PartialView("_IPOmasterList", data);
}

Main View:

<div id="ipoContainer"></div>

<script>
function loadIPO(page) {
    $("#ipoContainer").load('/Admin/IPOmasterList?page=' + page);
}

$(document).ready(function () {
    loadIPO(1);
});
</script>

Why beginners should learn this:

  • No full page reload

  • Faster UI

  • Works well for large datasets

This is the accepted MVC version of UpdatePanel.

3. jQuery DataTables with Server-Side Processing – Advanced but Beginner-Understandable

When the application requires searching, sorting, and paging together, DataTables in server-side mode is the best solution.

Even though the code is advanced, the concept is simple:

The browser asks the server only for the data it needs.

View:

<table id="ipoTable" class="table table-bordered">
    <thead>
        <tr>
            <th>Symbol</th>
            <th>Category</th>
            <th>Date</th>
        </tr>
    </thead>
</table>

<script>
$('#ipoTable').DataTable({
    processing: true,
    serverSide: true,
    ajax: {
        url: '/Admin/GetIPOData',
        type: 'POST'
    },
    columns: [
        { data: 'symbol' },
        { data: 'category' },
        { data: 'createdDate' }
    ]
});
</script>

Controller:

[HttpPost]
public IActionResult GetIPOData()
{
    var request = HttpContext.Request.Form;

    int start = int.Parse(request["start"]);
    int length = int.Parse(request["length"]);

    var query = _context.IPOmaster.AsNoTracking();
    int totalRecords = query.Count();

    var data = query
        .OrderByDescending(x => x.CreatedDate)
        .Skip(start)
        .Take(length)
        .Select(x => new {
            symbol = x.Symbol,
            category = x.Category,
            createdDate = x.CreatedDate.ToString("dd-MM-yyyy")
        })
        .ToList();

    return Json(new {
        draw = request["draw"],
        recordsTotal = totalRecords,
        recordsFiltered = totalRecords,
        data
    });
}

Why this is important:

  • Handles lakhs of records easily

  • Search and sort happen on the server

  • Used in real enterprise systems

4. ViewComponent – Clean and Reusable (Advanced Concept Explained Simply)

ViewComponents are useful when the same data grid appears in multiple places.

ViewComponent:

public class IPOmasterViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(int page = 1)
    {
        var data = GetPagedIPOData(page);
        return View(data);
    }
}

View usage:

@await Component.InvokeAsync("IPOmaster", new { page = 1 })

For beginners:

  • Think of ViewComponent as a mini-controller + view

  • Keeps code clean and reusable

Final Recommendation for Beginners

Start with:

  • HTML Table + Razor
    Then move to:

  • Partial View + AJAX
    Finally adopt:

  • jQuery DataTables (Server-side) for large data

Avoid loading all records at once. This is the most common beginner mistake.

Conclusion

ASP.NET Core MVC encourages developers to think in terms of performance and scalability. By learning simple Razor tables first and gradually moving to AJAX and server-side DataTables, even beginners can build applications that handle lakhs of records efficiently.

These techniques are not only beginner-friendly but also production-ready.