GridColumn does not have a property ChildContent

Environment

Product Grid for Blazor

Description

When opening the page I get an error

Telerik.Blazor.Components.GridColumn' does not have a property matching the name 'ChildContent'.

similar code is used somewhere else in the application without any problems

Steps to Reproduce

<TelerikGrid Data="@MyData" Sortable="true" Height="500px">
    <GridColumns>
        <GridColumn Field="ID"></GridColumn>
        <GridColumn Field="TheName" Title="Employee Name">
            @*<Template>some template</Template>*@
            @* Adding comments while debuging or trying things out causes the exception *@
        </GridColumn>
    </GridColumns>
</TelerikGrid>

@code {
    public IEnumerable<object> MyData = Enumerable.Range(1, 50).Select(x => new { ID = x, TheName = "name " + x });
}

Error Message

InvalidOperationException: Object of type 'Telerik.Blazor.Components.GridColumn' does not have a property matching the name 'ChildContent'.

Cause\Possible Cause(s)

Having a comment in the grid column tag definition causes such an exception. The razor engine tries to add it as content of the column (basically, an unnamed RenderFragment), but the GridColumn has several named RenderFragment instances, so it cannot have an unnamed one.

Solution

Remove comments entirely.

If you want to keep certain code so you can put it back in later, move it outside of the grid, or comment out the entire column and add a simple copy of its basic definition (field, size, etc.) without the comments.

In this article
Not finding the help you need? Improve this article