-
Notifications
You must be signed in to change notification settings - Fork 0
BlazorAddressTable
This wiki page documents how to add a razor component which is similar to the Index Page/View when CRUD pages/views are scaffolded in MVC or Razor Pages.
The View (Details) CRUD page in this case is only worth creating as a Razor component so that it can be used when customers want to see their addresses individually. The Edit/Create pages can be created as a single Upsurt Razor Component.

Make sure that you put a using directive to all your folders
@using BlazorShoes
@using BlazorShoes.Models
@using BlazorShoes.Services
@using BlazorShoes.Shared
@using BlazorShoes.ControllersYour AddressService or your AddressesControler must be injected into the table
@page "/Addresses/Index"
@inject AddressService addressService
@inject AddressesController controller;
<h3>Customer Addresses</h3>
<p>
<a class="btn btn-primary" href="Addresses/Create">Add New Address</a>
</p>
<table class="table">
<thead>
<tr>
<th>House No</th>
<th>House Name</th>
<th>Road Name</th>
<th>Town</th>
<th>Postcode</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in Addresses)
{
<tr>
<td>@item.HouseNumber</td>
<td>@item.HouseName</td>
<td>@item.RoadName</td>
<td>@item.PostTown</td>
<td>@item.Postcode</td>
<td>
<a class="btn btn-success" href="/Addresses/Edit/@item.AddressId">Edit</a>
<a class="btn btn-info" href="/Addresses/Details/@item.AddressId">View</a>
<a class="btn btn-danger" href="/Addresses/Delete/@item.AddressId">Delete</a>
</td>
</tr>
}
</tbody>
</table>@code
{
public List<Address> Addresses { get; set; }
//private AddressesController controller;
protected override void OnInitialized()
{
Addresses = controller.GetAddresses();
//Addresses = addressService.GetAddresses();
}
}BNU CO550 Web Applications | Dr Derek Peacock | 2022 Semester 1
Recorded Videos
ASP.NET Core 8
Blazor
React
MS Fabric
Filtering Products
Partial Pages
Git & GitHub
2021 Project Demos
Blazor CRUD
Address Service
API Controller
AddressTable 1
AddressTable 2
Upsert Address
Logbooks
LogBook 1
LogBook 2
LogBook 3
LogBook 4
LogBook 5