I have a Blazor solution with 3 project. There is the main app, a rest service for data, and a shared class project for EF.
Lots of detail below. What is interesting is that I have done this for another EF class. Exact same code (as far as I can tell), and it works perfectly. I feel I have flubbed something in the code. The error message isn't really helping me out. Hopefully someone has seen something like this.
I am getting the following error.
CS0029
Cannot implicitly convert type 'Syncfusion.Blazor.Grids.SfGrid<dataCatAdminBLZ.Shared.FieldGrouping>' to 'Syncfusion.Blazor.Grids.SfGrid<dataCatAdminBLZ.App.Pages.FieldGroupingEdit>'
dataCatAdminBLZ.App
..<path>\Files\GIT\dataCatAdminBLZ\dataCatAdminBLZ.App\Pages\FieldGroupingEdit.razor 1 Active
The first part .Shared.FieldGrouping is referencing an class with properties defining a database table
The second part is referring to the blazor page. In the CS partial class for the page there is code that does:
protected override async Task OnInitializedAsync()
{
FieldGroupingA = (await FieldGroupingDataServiceP.FieldGroupings()).ToList();
}
I have build a razor page with a sfgrid component on it. The grid binds to the class define in the CS.
<SfGrid DataSource=@FieldGroupingA class="mr-2" @ref="@Grid_Resolved"
AllowPaging="true"
AllowFiltering="false"
AllowSorting="true"
AllowTextWrap="true"
AllowResizing="true"
AllowGrouping="false"
RowHeight="30"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true"
AllowDeleting="true"
AllowEditing="true" />
<GridPageSettings PageSize="40"></GridPageSettings>
@*<GridEvents OnRecordDoubleClick="RecordDoubleClickHandler" TValue="FileTemplateHeader"></GridEvents>*@
<GridColumns>
<GridColumn Field=@nameof(FieldGrouping.Agsan) HeaderText="AGSAN" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="4" />
<GridColumn Field=@nameof(FieldGrouping.GrpName) HeaderText="Group Name" IsPrimaryKey="false" TextAlign="TextAlign.Left" Width="20"></GridColumn>
<GridColumn Field=@nameof(FieldGrouping.GrpDesc) HeaderText="Group Desc" IsPrimaryKey="false" TextAlign="TextAlign.Left" Width="30"></GridColumn>
</GridColumns>
</SfGrid>
|
protected override async Task OnInitializedAsync()
{
FieldGroupingA = (await FieldGroupingDataServiceP.FieldGroupings()).ToList();
} |
Attached are 2 screen shots showing the type. I have done this with another EF table and it works fine. This code looks the same, but clearly something is different. Attached is also a small sample solution demonstrating the issue and a screen shot showing the visual studio form and error message.
Thanks.
|
SfGrid<FieldGrouping> Grid_Resolved; |
|
<SfGrid DataSource=@FieldGroupingA class="mr-2" @ref="@Grid_Resolved"
AllowPaging="true"
AllowFiltering="false"
AllowSorting="true"
AllowTextWrap="true"
AllowResizing="true"
AllowGrouping="false"
RowHeight="30"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEditSettings AllowAdding="true"
AllowDeleting="true"
AllowEditing="true" />
<GridPageSettings PageSize="40"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(FieldGrouping.Agsan) HeaderText="AGSAN" IsPrimaryKey="true" TextAlign="TextAlign.Center" Width="4" />
<GridColumn Field=@nameof(FieldGrouping.GrpName) HeaderText="Group Name" IsPrimaryKey="false" TextAlign="TextAlign.Left" Width="20"></GridColumn>
<GridColumn Field=@nameof(FieldGrouping.GrpDesc) HeaderText="Group Desc" IsPrimaryKey="false" TextAlign="TextAlign.Left" Width="30"></GridColumn>
</GridColumns>
</SfGrid> |
Thanks. Cannot believe I missed that, but I knew it was going to be something small.
In the CS file, would you explain to me the meaning of this line?
SfGrid<FieldGrouping> Grid_Resolved;
In the razor file, seems to already have the reference to the dataset. Not sure I understand the purpose of this line.
Thanks again for the help.
Thanks for all of you help. I appreciate you responses.
Marc.