If EnvT is a field in the database then your design makes little sense.
Why?
I want to fill EnvT, which is defined in database, when I create and edit the line from DataGrid (CRUD).
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I've a class model as below
public partial class Developer
{
public int Id { get; set; }
public int _currentYear = DateTime.Today.Year;
public string EnvT { get { return _currentYear.ToString(); } }
}
I want to retrieve EnvT in TextBox as below
<EditForm Model="@dev" OnValidSubmit="@OnValidSubmit">
<DataAnnotationsValidator />
<RadzenTextBox style="width: 100%;" Name="Numéro EnvT" @bind-Value=@dev.EnvT Disabled=true/>
<ValidationMessage For="@(() => dev.EnvT)" />
</EditForm>
Edit razor page is
<FormEdit ButtonText="Update" dev="dev"
OnValidSubmit="@EditDeveloper" />
@code {
[Parameter] public int developerId { get; set; }
Developer dev = new Developer();
protected async override Task OnParametersSetAsync()
{
dev = await http.GetFromJsonAsync<Developer>($"api/developer/{developerId}");
}
async Task EditDeveloper()
{
await http.PutAsJsonAsync("api/developer", dev);
await js.InvokeVoidAsync("alert", $"Updated Successfully!");
uriHelper.NavigateTo("developer");
}
I've a message error : Property or indexer 'property' cannot be assigned to -- it is read only
I don't how why I've this error.
Do I have to do this to find the EnvT value in the database table?
Thanks in advance!
If EnvT is a field in the database then your design makes little sense.
Why?
I want to fill EnvT, which is defined in database, when I create and edit the line from DataGrid (CRUD).
It might seem to work today but next year EnvT will return 2023 while the table could contain 2022.
It's exactly what I want; each line of my table will have 2022 for EnvT and when the Year Change the new line of the table will take 2023.
Is there a problem with doing this?
Do you have a counter example?