i have a problem with my @bind-Value
is always coming up NULL
@page "/database"
<PageTitle>Database</PageTitle>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h1 class="card-title text-center">DataBase Insert</h1>
<br />
<br />
<EditForm Model="@employee" method="post" OnValidSubmit="AddNewEmployee" FormName="registerMaster">
<div class="form-floating mb-3">
<InputText @bind-Value="employee.Name" class="form-control" placeholder="Name" />
<label for="Name">Name</label>
</div>
<div class="form-floating mb-3">
<InputNumber @bind-Value="employee.Age" class="form-control" placeholder="Age" />
<label for="Age">Age</label>
</div>
<div class="form-floating mb-3">
<InputText value="employee.Title" class="form-control" placeholder="Title" />
<label for="Title">Title</label>
</div>
<div class="form-floating mb-3">
<InputText @bind-Value="employee.Gender" class="form-control" placeholder="Gender" />
<label for="Gender">Gender</label>
</div>
<button type="submit" class="btn btn-primary btn-rounded">Submit</button>
</EditForm>
</div>
</div>
</div>
</div>
@inject Data.AppDbContext DbContext
@code{
public Employee employee = new Employee();
public async Task AddNewEmployee()
{
DbContext.Employees.Add(employee);
await DbContext.SaveChangesAsync();
}
}
I tried @bind-value=""
that just straight give me a error to use @bind-Value
can someone explain what am i missing
New contributor
Syed Muhammad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.