Select theme:
RadzenGrid component, @addTagHelper and .cshtml pages it uses no longer apply. Use the quick start below, or browse the live Radzen Blazor DataGrid demos with source code.
1. Install the Radzen.Blazor package and set up the theme and services as described in Get started.
2. Add a RadzenDataGrid to an interactive page and bind it to your data. When Data is an IQueryable, such as an Entity Framework Core DbSet, paging, sorting and filtering run in the database and only the current page is loaded.
@page "/products"
@rendermode InteractiveServer
@inject NorthwindContext context
<RadzenDataGrid Data="@products" AllowPaging="true" AllowSorting="true" AllowFiltering="true" PageSize="10">
<Columns>
<RadzenDataGridColumn Property="@nameof(Product.ProductName)" Title="Product Name" />
<RadzenDataGridColumn Property="@nameof(Product.UnitPrice)" Title="Unit Price" FormatString="{0:C}" />
<RadzenDataGridColumn Property="@nameof(Product.UnitsInStock)" Title="Units In Stock" />
<RadzenDataGridColumn Property="@nameof(Product.Discontinued)" Title="Discontinued" />
</Columns>
</RadzenDataGrid>
@code {
IQueryable<Product> products;
protected override void OnInitialized()
{
products = context.Products;
}
}
NorthwindContext is an EF Core DbContext registered with AddDbContext in Program.cs. Grouping, virtualization, inline editing, export and more are in the DataGrid demos.
Radzen.Blazor is a free UI component suite for Blazor applications that we shipped with Radzen's experimental Blazor support.
Today I'm going to show you how to use the powerful Blazor DataGrid component to display, sort and page your data. Paging and sorting is supported automatically for in-memory collections and if your data source is IQueryable all queries will be executed in the database (if you are using Entity Framework Core and MS SQL Server for example).
Here is how start using the Radzen Blazor DataGrid in your Blazor applications.
1. Create new Blazor (server-side) application.

2. Add a reference to Radzen.Blazor and register the Radzen Blazor components using @addTagHelper in ~/_ViewImports.cshtml.
@addTagHelper *,Radzen.Blazor

3. Open FetchData.cshtml, replace the HTML table with RadzenGrid and run the application.
<RadzenGrid AllowSorting="true" Data="@forecasts" TItem="WeatherForecast">
<Columns>
<RadzenGridColumn TItem="WeatherForecast" Context="data" Property="Date" Title="Date" Type="DateTime">
<Template>
@data.Date.ToShortDateString()
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="WeatherForecast" Context="data" Property="TemperatureC" Title="TemperatureC" Type="int">
<Template>
@data.TemperatureC
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="WeatherForecast" Context="data" Property="TemperatureF" Title="TemperatureF" Type="int">
<Template>
@data.TemperatureF
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="WeatherForecast" Context="data" Property="Summary" Title="Summary" Type="string">
<Template>
@data.Summary
</Template>
</RadzenGridColumn>
</Columns>
</RadzenGrid>

4. Open Services\WeatherForecastService.cs, add some more records, set AllowPaging to True for RadzenGrid and run the application.

Now let's bind the data grid to the good old Northwind SQL Server database using Entity Framework Core.
5. Add references to Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.Relational and Microsoft.EntityFrameworkCore.SqlServer.

6. Create a new Northwind.cs file. It will contain the EF DbContext and a Product class mapped to the Products table from the Northwind database.
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WebApplication1.App.Northwind
{
public partial class NorthwindContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
// Update the connection string to use your local MS SQL server
optionsBuilder.UseSqlServer("Server=.;Initial Catalog=Northwind;Persist Security Info=False;Integrated Security=true;MultipleActiveResultSets=False;Encrypt=false;TrustServerCertificate=true;Connection Timeout=30");
}
}
public DbSet<Product> Products
{
get;
set;
}
}
[Table("Products", Schema = "dbo")]
public partial class Product
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ProductID
{
get;
set;
}
public string ProductName
{
get;
set;
}
public int? SupplierID
{
get;
set;
}
public int? CategoryID
{
get;
set;
}
public string QuantityPerUnit
{
get;
set;
}
public decimal? UnitPrice
{
get;
set;
}
public Int16? UnitsInStock
{
get;
set;
}
public Int16? UnitsOnOrder
{
get;
set;
}
public Int16? ReorderLevel
{
get;
set;
}
public bool? Discontinued
{
get;
set;
}
}
}
7. Register the NorthwindContext as a singleton in Startup.cs. This allows you to inject it in FetchData.cshtml.
Query Products and assign the result to the products field.
Startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Since Blazor is running on the server, we can use an application service
// to read the forecast data.
services.AddSingleton<WeatherForecastService>();
// Register the NorthwindContext so you can inject it to your Blazor pages
services.AddSingleton<NorthwindContext>();
}
public void Configure(IBlazorApplicationBuilder app)
{
app.AddComponent<App>("app");
}
}
FetchData.cshtml
@inject NorthwindContext context
IQueryable<Product> products;
protected override async Task OnInitAsync()
{
products = await Task.FromResult(context.Products.AsQueryable());
}
8. Bind RadzenGrid to products and add a few columns.
<RadzenGrid AllowPaging="true" AllowSorting="true" Data="@products" TItem="Product">
<Columns>
<RadzenGridColumn TItem="Product" Context="data" Property="ProductID" Title="Product ID" Type="integer">
<Template>
@data.ProductID
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Property="ProductName" Title="Product Name" Type="string">
<Template>
@data.ProductName
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Property="SupplierID" SortProperty="Supplier.CompanyName" Title="Supplier" Type="string">
<Template>
@data.Supplier?.CompanyName
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Property="CategoryID" SortProperty="Category.CategoryName" Title="Category" Type="string">
<Template>
@data.Category?.CategoryName
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Property="QuantityPerUnit" Title="Quantity Per Unit" Type="string">
<Template>
@data.QuantityPerUnit
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Format="decimal" Property="UnitPrice" Title="Unit Price" Type="number">
<Template>
@data.UnitPrice
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Format="int16" Property="UnitsInStock" Title="Units In Stock" Type="integer">
<Template>
@data.UnitsInStock
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Format="int16" Property="UnitsOnOrder" Title="Units On Order" Type="integer">
<Template>
@data.UnitsOnOrder
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Format="int16" Property="ReorderLevel" Title="Reorder Level" Type="integer">
<Template>
@data.ReorderLevel
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Product" Context="data" Property="Discontinued" Title="Discontinued" Type="boolean">
<Template>
@data.Discontinued
</Template>
</RadzenGridColumn>
</Columns>
</RadzenGrid>
9. Run the application and you will see the Radzen DataGrid component data-bound to the Products table of the Northwind database. If you sort or change the current page you will notice that the queries are executed by your SQL Server and only the current page of data is requested.

Enjoy!
Radzen Blazor Components v12.1: AI Chat with Tool Calling, AIPrompt, Smart Paste, and More
Radzen Blazor Components v12.0: Markdown Editor, Resource Scheduling, Browser Export, and More
34 UI Block categories. 200+ blocks. 1,170+ variants.
The Radzen Roadmap: What's Shipped and What's Next
Blazor Charts Deep Dive: Candlestick, Box Plot, Waterfall, and 30+ More Free Chart Types
Radzen Blazor Components v11.0: Spreadsheet, 30+ New Charts, and More
RadzenSpreadsheet: a Free and Open-Source Blazor Spreadsheet
Radzen is free to use. You can also test the premium features for 15 days.
Start FreeSelect theme: