Blazor Data Grid Not Displaying Found Records from MSSQL

Finding Radzen Blazor Components are going to help me for internal projects.

Below I am listing an issue that I am having but not finding an example to use to see about correcting the issue. I have googled, youtube, and read forms on websites and I am still having the issue.

Issue: Radzen Data Grid is displaying DataAccessLibrary per record found instead of the actual record

Goal: is to have the Found record(s) display in the Data Grid

Using Visual Studio 2019
Installed Radzen Blazor Components
Connected to an Existing SQL server for a defined database

Using Radzen Tabs with Radzen Data Grid

The Tabs work, and the header on the Data Grid work as well. As seen in the screen capture, it is listting DataAccessLibrary for the 1 record (If there are more than 1 record it just repeats that is being shown).

The Above Rendered .razor Page uses this code:

@Page "<page URL/{vID:int}>"
@using DataAccessLibrary.Models


    <RadzenTabsItem Text="Contacts" Icon="person">
    <RadzenGrid Count="@ContactCount" Data="@vendorContacts" LoadData="@OnLoadContacts" TItem="VendorContact" AllowPaging="true" PageSize="4">
     <RadzenGridColumn TItem="VendorContact" Property="PersonName" Title="Name" />
    <RadzenGridColumn TItem="VendorContact" Property="Email" Title="Email Address" />
    <RadzenGridColumn TItem="VendorContact" Property="Phone1" Title="Phone" />
    <RadzenGridColumn TItem="VendorContact" Property="PhoneExtention1" Title="Phone Extension" />
    <RadzenGridColumn TItem="VendorContact" Property="Phone2" Title="alt Phone" />
    <RadzenGridColumn TItem="VendorContact" Property="PhoneExtention2" Title="ALT Phone Extension" />
    <RadzenGridColumn TItem="VendorContact" Property="InactiveDate" Title="InactiveDate" />


in the @code section of the page the following is done

public List<VendorContact> vendorContacts;

    async Task OnLoadContacts()
        vendorContacts = await _db.GetVendorContacts(vID);
        ContactCount = vendorContacts.Count();
        await InvokeAsync(StateHasChanged);

Hi @crystalcu,

I edited your post to format the code ...

The provided code looks correct and should have worked. What happens when you debug the OnLoadContacts method? Does it return the expected data? Does it work if you delete the LoadData handler and set vendorContacts in the OnInitializedAsync method of your page instead? Also do you know what "DataAccessLibrary" could be? It can't come from nowhere.

THANKS for the formatting. (Sorry if I call things wrong! Still learning c#

DataAccessLibrary is a project within a Solution (VS2019) that I am working with at this time. It contains, the access to the server/Database which I know is MS SQL, also, a Copy of the Classes/Models of the records that are being found in the Database tables used in the 2nd project of the solution. The Methods to get the data as well (eq: GetVendorsList() .) The 2nd project of the solution has a reference to DataAccessLibrary and @Using DataAccessLibrary is being included with each Blazor razor page that is being created. As Example VendorContact class/model is defined in this library.

What I have done so far:

  1. Removed the LoadData from the RadzenGrid line and I get a compile error until I put it back in.

  2. Originally, the vendorContacts, which is a List of VendorContact, was being loaded in the OnInitializedAsync() method, but was being returned Null for the data in debug when the example that I was had 1 record, with a second example returned Null and it had 2 records. The record counts are from MS SQL query (select count(*) from VendorContact where VendorID = 1 ) of the table. Was thinking of a possible double read/get issue. As I moved it outside of the OnInitializedAsync() method to it's own and stepped through with debug the page that was rendering, I was getting record(s) being returned. But the record(s) were not displaying.

I have done the following and got my information to display.

Added Titem to the line and added the Context="data" to the RadzenGridColumn Lines.

 <RadzenGrid Count="@ContactCount" Data="@vendorContacts" TItem="VendorContact" AllowPaging="true" PageSize="4" >
                   <RadzenGridColumn TItem="VendorContact" Context="data" Property="PersonName" Title="Name"></RadzenGridColumn>

As seen in the following screen shot:

The Topic of Not displaying can closed.

As can be seen Screen I have a formatting issue I need to go figure out.

Thank you all that do watch these Topics and answer.