@page "/fetchdata" @using WebApplication2.Data @inject IDataRepository _repository @if (departments == null) {

Loading...

} else { @foreach (var department in departments) { @* @onclick="@(e => RowClick(e, department.DepId))"*@ }
DepId DepName Description Select
@department.DepId @department.DepName @department.Description
} @if (employees == null) {

Employee is empty

} else { @foreach (var employee in employees) { }
EmpId EmpName Email
@employee.EmpId @employee.EmpName @employee.Email
} @code { private List departments; private List employees; protected override async Task OnInitializedAsync() { departments = await _repository.GetDepartmentsAsync(); } private async Task RowClick(MouseEventArgs e, int depid) { employees = await _repository.GetEmployeesByDepIdAsync(depid); } }