Getting Started with the ASP.NET Core DataGrid Control

23 Jul 20269 minutes to read

This section briefly explains how to include the ASP.NET Core DataGrid control in your ASP.NET Core Web App using Visual Studio and Visual Studio Code.

Ready to streamline your ASP.NET Core development? Discover the full potential of ASP.NET Core controls with AI Coding Assistant. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like Visual Studio, Visual Studio Code, Cursor, Code Studio and more. Explore AI Coding Assistant

To get started quickly with ASP.NET Core DataGrid control, you can check out this video.

Prerequisites

.NET and Visual Studio compatibility

.NET version Minimum Visual Studio version
.NET 10.0 Visual Studio 2026 18.0.0 or later
.NET 9.0 Visual Studio 2022 17.12.0 or later
.NET 8.0 Visual Studio 2022 17.8.0 or later
.NET Core SDK 3.1 Visual Studio 2019 16.4 or later
.NET Core SDK 2.0 Visual Studio 2017 15.7 or later

Browser support

Browser Versions
Google Chrome, including Android & iOS Latest Version
Mozilla Firefox Latest Version
Microsoft Edge Latest Version
Apple Safari, including iOS Latest Version
Opera Latest Version
Microsoft Internet Explorer 11

Create an ASP.NET Core Web App with Razor Pages

Create an ASP.NET Core Web App using Visual Studio via Microsoft Templates or the ASP.NET Core Extension.

Run the following command to create a new ASP.NET Core Web App.

dotnet new webapp -o RazorPagesGrid
code -r RazorPagesGrid

Alternatively, create an ASP.NET Core Web App using Visual Studio Code via Microsoft Templates or the ASP.NET Core Extension, or the C# Dev Kit extension.

Install the required ASP.NET Core packages

Install the Syncfusion.AspNetCore.Grid and Syncfusion.AspNetCore.Themes NuGet packages. All Syncfusion ASP.NET Core packages are available on nuget.org. See the NuGet packages topic for more details.

  1. Go to Tools → NuGet Package Manager → Manage NuGet Packages for Solution.
  2. Search the required NuGet packages (Syncfusion.AspNetCore.Grid and Syncfusion.AspNetCore.Themes) and install them.

Alternatively, you can install the same packages using the Package Manager Console with the following commands.

Install-Package Syncfusion.AspNetCore.Grid -Version 34.1.29
Install-Package Syncfusion.AspNetCore.Themes -Version 34.1.29

Open the terminal and run the following commands.

dotnet add package Syncfusion.AspNetCore.Grid --version 34.1.29
dotnet add package Syncfusion.AspNetCore.Themes --version 34.1.29

Add ASP.NET Core tag helpers

After the packages are installed, open the ~/Pages/_ViewImports.cshtml file and import the Syncfusion.AspNetCore.Grid and Syncfusion.AspNetCore.Base tag helpers.

@addTagHelper *, Syncfusion.AspNetCore.Grid
@addTagHelper *, Syncfusion.AspNetCore.Base

Add stylesheet and script resources

The theme stylesheet and script can be referenced from NuGet through Static Web Assets. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml file.

<head>
    ...
    <link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
    <script src="_content/Syncfusion.AspNetCore.Grid/scripts/sf-grid.min.js"></script>
</head>

Register the script manager

Open the ~/Pages/Shared/_Layout.cshtml file and register the script manager (<ejs-scripts>) at the end of the <body> element as shown below.

<body>
    ...
    <!-- Syncfusion ASP.NET Core Script Manager -->
    <ejs-scripts></ejs-scripts>
</body>

Add the ASP.NET Core DataGrid control

Add the ASP.NET Core DataGrid control in the ~/Pages/Index.cshtml file.

@page
@model IndexModel
 
@{
    List<Order> orders = new List<Order>
    {
        new Order(10248, "Ana Trujillo", new DateTime(2025,1,12), "France", 32.38),
        new Order(10249, "Martin Sommer", new DateTime(2025,1,15), "Germany", 11.61),
        new Order(10250, "Thomas Hardy", new DateTime(2025,2,5), "Brazil", 65.83),
        new Order(10251, "Elizabeth Lincoln", new DateTime(2025,2,18), "France", 41.34),
        new Order(10252, "Victoria Ashworth", new DateTime(2025,3,10), "Belgium", 51.30),
        new Order(10253, "Martine Rance", new DateTime(2025,3,22), "Brazil", 58.17)
    };
}
 
<ejs-grid id="Grid" dataSource="@orders">
    <e-grid-columns>
        <e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
        <e-grid-column field="CustomerID" headerText="Customer ID" width="150"></e-grid-column>
        <e-grid-column field="OrderDate" headerText="Order Date" width="130" textAlign="Right" format="yMd"></e-grid-column>
        <e-grid-column field="Freight" headerText="Freight" width="100" textAlign="Right" format="C2"></e-grid-column>
        <e-grid-column field="ShipCountry" headerText="Ship Country" width="120"></e-grid-column>
    </e-grid-columns>
</ejs-grid>
....
....
public class IndexModel : PageModel
{
    public void OnGet() { }
}

public class Order
{
    public Order() { }
    public Order(int id, string customer, DateTime date, string country, double freight)
    {
        this.OrderID = id;
        this.CustomerID = customer;
        this.OrderDate = date;
        this.ShipCountry = country;
        this.Freight = freight;
    }

    public int? OrderID { get; set; }
    public string CustomerID { get; set; }
    public DateTime? OrderDate { get; set; }
    public string ShipCountry { get; set; }
    public double? Freight { get; set; }
}

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. The ASP.NET Core DataGrid control will render in your default web browser.

Open the terminal and run the following command.

dotnet run

ASP.NET Core DataGrid with Columns Data

See also

  1. Getting Started with ASP.NET Core in Visual Studio Mac
  2. Getting Started with ASP.NET Core MVC using Tag Helper