Hello,
I have edited the code below to remove a lot of the non-relevant parts. In summary I have a TelerikDropDownList within a TelerikGrid EditorTemplate within a TelerikWindow. When I click "Add" in the grid a NullReferenceException exception is thrown (full Exception text at the bottom of the post). If I comment out the DropDownList control completely, the exception is not thrown when I click "Add".
<TelerikWindow>
<TelerikWindowContent>
<TelerikGrid Data=@ScheduledJobs EditMode="inline">
<TelerikGridToolBar>
<TelerikGridCommandButton Command="Add" Icon="add"></TelerikGridCommandButton>
</TelerikGridToolBar>
<TelerikGridColumns>
<TelerikGridColumn Field=@nameof(ScheduledJob.JobActionName) Title="Action">
<EditorTemplate>
@{
JobToEdit = context as ScheduledJob;
<TelerikDropDownList DefaultItem="@DefaultJobAction" Data="@JobActions" bind-Value=@JobToEdit.JobAction ValueField="@nameof(JobAction.Id)" TextField="@nameof(JobAction.Name)"></TelerikDropDownList>
}
...
@functions {
protected List<JobAction> JobActions = <code to populate JobActions list>
protected DefaultJobAction = JobActions[0]; // I have debugged - this assigns a non-null object as expected
protected JobToEdit JobToEdit; // has a field called JobAction of type JobAction
}
The full exception text is:
System.NullReferenceException: Object reference not set to an instance of an object. at string Telerik.Blazor.Common.TelerikSelectBase<TValue>.get_CurrentValueAsString() at void Telerik.Blazor.Components.DropDownList.TelerikDropDownList<TItem, TValue>.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase()+(RenderTreeBuilder builder) => { } at void Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment) at void Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry) at void Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()