I have a grid with one column. I'm trying to add rows to it based on a lookup list.
The grid displays the data correctly. When I enter edit mode the combo box displays the Tags: "Weights", "Cardio", "Toning", "HIT", "Dumbell". But when I select an item I get a null reference.
How can I fix this issue?
My SFGrid data source uses:
public List<ExerciseTagsModel> GridData = new List<ExerciseTagsModel>();
public class ExerciseTagsModel
{
public int ID { get; set; }
public int ExerciseID { get; set; }
public string Tag { get; set; }
}
The SFCombobox data source uses:
Tags = new List<string>() { "Weights", "Cardio", "Toning", "HIT", "Dumbell" };
Here's the grid markup:
<SfGrid TValue="ExerciseTagsModel"
@ref="@gridInstance"
DataSource="@GridData"
Toolbar="@(new List<string>() {
"Add", "Delete", "Cancel"
})">
<GridEditSettings Mode="EditMode.Normal"
AllowAdding="true"
AllowDeleting="true"
AllowEditing="true"
ShowDeleteConfirmDialog="true">
</GridEditSettings>
<GridEvents DataBound="DataBoundHandler"
OnActionComplete="ActionCompletedHandler"
TValue="ExerciseTagsModel">
</GridEvents>
<GridColumns>
<GridColumn Visible="false"
Field=@nameof(ExerciseTagsModel.ID)
HeaderText="ID"
TextAlign="TextAlign.Center"
IsPrimaryKey="true">
</GridColumn>
<GridColumn Field=@nameof(ExerciseTagsModel.Tag)
HeaderText="@L["Tags_"]"
TextAlign="TextAlign.Center">
<EditTemplate>
<SfComboBox @bind-Value="@tagValue"
AllowCustom="true"
TItem="string"
TValue="string"
DataSource="@Tags"
AllowFiltering="true">
</SfComboBox>
</EditTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
Here is the NullReferenceExceptions text:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Syncfusion.Blazor
StackTrace:
at Syncfusion.Blazor.Grids.Internal.PropertyInfoHelper.CreateAccessor(PropertyInfo propertyInfo)