Welcome to the Blazor feedback portal. We’re happy you’re here! If you have feedback on how to improve the Blazor, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

I have a .NET 8 Blazor WebApp site running in InteractiveServer render mode. I created a page where I'm rendering a form using an SfDataForm. The form is bound to a model via the EditContext.

There's a portion of the form where I need to loop through a child collection. It looks like this.

@foreach (BoilerplateParameter parameter in Model.Boilerplate.Parameters)
{
    <FormItem EditorType="FormEditorType.TextBox">
        <Template>
            <SfTextBox @bind-Value="parameter.Value"></SfTextBox>
        </Template>
    </FormItem>
}

When I do this, I get a NullReferenceException from Syncfusion. This is the stack trace:


System.NullReferenceException: Object reference not set to an instance of an object.

   at Syncfusion.Blazor.DataForm.FormItems.b__50_3(RenderTreeBuilder __builder5)

   at Microsoft.AspNetCore.Components.CascadingValue`1.Render(RenderTreeBuilder builder)

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)

   at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()

   at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()

   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

   at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters)

   at Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.BeginRenderingComponent(IComponent component, ParameterView initialParameters)

   at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.RenderEndpointComponent(HttpContext httpContext, Type rootComponentType, ParameterView parameters, Boolean waitForQuiescence)

   at Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context)

   at Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context)

   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<b__10_0>d.MoveNext()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)


However, I found that this works, though I don't get the benefits of FormItem and the form doesn't look right.

@foreach (BoilerplateParameter parameter in Model.Boilerplate.Parameters)
{
    <SfTextBox @bind-Value="parameter.Value"></SfTextBox>
}

I'm not sure how to work around this one, as the exception seems to be happening within the Syncfusion framework, and it's not giving me a lot of info to go on here. I attached a sample app that will demonstrate this problem. Please advise.