|
EditForm Model="@model" OnValidSubmit="@Create">
<SfComboBox TValue="int?"
TItem="User"
DataSource="@Users"
AllowCustom="false"
@bind-Value="@model.AssignedTo"
ShowClearButton="true"
Autofill="true">
<ComboBoxFieldSettings Text="Name" Value="ID"></ComboBoxFieldSettings>
</SfComboBox>
<SfTextBox Placeholder="Title" @bind-Value="model.Title" />
<ValidationSummary />
<button type="submit">Create</button>
</EditForm>
@code{
public Model model { get; set; }
public class Model
{
[Required]
public int? AssignedTo { get; set; }
[Required]
public string Title { get; set; }
}
public class User
{
public int? ID { get; set; }
public string Name { get; set; }
}
public List<User>
Users = new List<User>()
{
new User() { ID = 1, Name = "a a" },
new User() { ID = 4, Name = "b b" },
new User() { ID = 5, Name = "c c" }
};
protected override async Task OnInitializedAsync()
{
model = new Model();
await base.OnInitializedAsync();
}
public void Create()
{
}
}
|