Hi, i'm trying adding data to List, not to connect with database, but the data grid not updating.
Here is a code sample, the <li> data is updating with current list, but SfGrid still showing empty after adding data to list.
Any help would be greatly appreciated, thanks.
@page "/Test"
<input type="text" @bind="@newPerson.Name" placeholder="Name" /> <input type="number" @bind="@newPerson.Age" placeholder="Age" /> <button @onclick="AddPerson">Add Person</button>
<ul> @foreach (var person in people) { <li>@person.Name, @person.Age</li> } </ul> <SfGrid DataSource="@people" />
@code { private List<Person> people = new List<Person>(); private Person newPerson = new Person();
private void AddPerson() { people.Add(newPerson); newPerson = new Person(); StateHasChanged(); }
public class Person { public string Name { get; set; } public int Age { get; set; } } } |