Locked on datalist

since a days i'm trying to implement a datalist in my app. In fact, I'd like to create a editable list that must add new lines in a table located in my database. The problem is when I load datas in the component it only allow me to update existing line of the database. does anyone have a solution to provide ?

rozor's page code :

'"

@page "/add-t-evaluer"

@attribute [Authorize]

Add TEvaluer

    <Template Context="tEvaluer">
        <RadzenTemplateForm TItem="SurgeSurvey.Models.SURGE_TEST.TEvaluer" Data="@tEvaluer" Visible="@(tEvaluer != null)" Submit="@FormSubmit" >

        
            <RadzenColumn SizeMD="9" Style="margin-top: 10px; margin-bottom: 10px; background-color: rgba(244, 255, 199, 0.35)">
                <RadzenText TextStyle="TextStyle.H6" TagName="TagName.H5" class="rz-color-secondary">@(tEvaluer.identifiantCritere)</RadzenText>

                <RadzenDropDown Data="@tCriteresForidentifiantCritere" TextProperty="LibelleCritere" ValueProperty="identifiantCritere" AllowClear=false
                     Placeholder="Choose TCritere" style="display: block; width: 100%; text-align: center; color: #076f09; background-color: rgba(255, 255, 255, 0)" 
                     @bind-Value="@tEvaluer.identifiantCritere" Name="identifiantCritere" AllowSelectAll="false" Disabled="false" FilterAsYouType="false" ReadOnly="true"
                       />
            </RadzenColumn>


            <RadzenCard Style="color: #232476; background-color: #97c5d4; margin-top: 10px; margin-bottom: 10px">

                    <RadzenColumn SizeMD="9" Style="background-color: rgba(187, 247, 249, 0)">

                        <RadzenLabel Text="Membre Déployé" Component="TDeploier" style="width: 100%" />

                        <RadzenDropDown Data="@tDeploiersForIdentifiantDeploiement" TextProperty="IdentifiantMembre" ValueProperty="IdentifiantDeploiement" AllowClear=false
                            Placeholder="Choose TDeploier" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantDeploiement" Name="IdentifiantDeploiement"
                            />
                    <RadzenDropDown Data="@tDeploiersForIdentifiantDeploiement" TextProperty="IdentifiantMembre" ValueProperty="IdentifiantDeploiement" AllowClear=false
                            Placeholder="Choose TDeploier" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantDeploiement" Name="IdentifiantDeploiement"
                            />
                    <RadzenDropDown Data="@tDeploiersForIdentifiantDeploiement" TextProperty="IdentifiantMembre" ValueProperty="IdentifiantDeploiement" AllowClear=false
                            Placeholder="Choose TDeploier" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantDeploiement" Name="IdentifiantDeploiement"
                            />


                        </RadzenColumn>
            </RadzenCard>   
                    


            <RadzenCard Style="color: #9e1919; background-color: #dbc4c4; margin-top: 10px; margin-bottom: 10px" >

                    <RadzenColumn SizeMD="9">
                    
                    <RadzenLabel Text="Evaluateur DDS" Component="TEvaluateurDd" style="width: 100%" />
                    <RadzenDropDown Data="@tEvaluateurDdsForIdentifiantEvDDS" TextProperty="IdentifiantEvDDS" ValueProperty="IdentifiantEvDDS" AllowClear=false
                        Placeholder="Choose TEvaluateurDd" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvDDS" Name="IdentifiantEvDDS"
                        />
                    <RadzenDropDown Data="@tEvaluateurDdsForIdentifiantEvDDS" TextProperty="NomEvaluateurDDS" ValueProperty="IdentifiantEvDDS" AllowClear=false
                        Placeholder="Choose TEvaluateurDd" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvDDS" Name="IdentifiantEvDDS"
                        />
                    <RadzenDropDown Data="@tEvaluateurDdsForIdentifiantEvDDS" TextProperty="PrenomEvaluateurDDS" ValueProperty="IdentifiantEvDDS" AllowClear=false
                        Placeholder="Choose TEvaluateurDd" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvDDS" Name="IdentifiantEvDDS"
                        /> 
                        
                        <RadzenColumn SizeMD="9">
                            <RadzenNumeric style="display: block; width: 100%" @bind-Value="@tEvaluer.NoteDDS" Name="NoteDDS" />
                            <RadzenLabel Text="Note D D S" Component="NoteDDS" style="width: 100%" />
                        </RadzenColumn>
                </RadzenColumn>
            </RadzenCard>


                <RadzenCard Style="margin-top: 10px; margin-bottom: 10px; color: #b1c2b1; background-color: rgba(216, 226, 213, 0.82)">
                    <RadzenColumn SizeMD="9" Style="color: #116511">
                        
                        <RadzenLabel Text="Evaluateur OMS" Component="TEvaluateurOm" style="width: 100%, margin: 20px"/>
                        <RadzenDropDown Data="@tEvaluateurOmsForIdentifiantEvOMS" TextProperty="IdentifiantEvOMS" ValueProperty="IdentifiantEvOMS" AllowClear=false
                            Placeholder="Choose TEvaluateurOm" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvOMS" Name="IdentifiantEvOMS"
                            />
                        <RadzenDropDown Data="@tEvaluateurOmsForIdentifiantEvOMS" TextProperty="NomEvaluateurOMS" ValueProperty="IdentifiantEvOMS" AllowClear=false
                            Placeholder="Choose TEvaluateurOm" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvOMS" Name="IdentifiantEvOMS"
                            />
                        <RadzenDropDown Data="@tEvaluateurOmsForIdentifiantEvOMS" TextProperty="PrenomEvaluateurOMS" ValueProperty="IdentifiantEvOMS" AllowClear=false
                            Placeholder="Choose TEvaluateurOm" style="display: block; width: 100%" @bind-Value="@tEvaluer.IdentifiantEvOMS" Name="IdentifiantEvOMS"
                                />
                        <RadzenColumn >
                            <RadzenLabel Text="Note O M S" Component="NoteOMS" style="width: 100%" />
                            <RadzenNumeric style="display: block; width: 100%" @bind-Value="@tEvaluer.NoteOMS" Name="NoteOMS" />
                        </RadzenColumn>
                    
                    </RadzenColumn>

                </RadzenCard>


      <RadzenStack  Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem" Style="margin: 10px">
                <RadzenButton ButtonStyle="ButtonStyle.Primary" ButtonType="ButtonType.Submit" Icon="save" Text="ajouter" Variant="Variant.Flat" />
                <RadzenButton ButtonStyle="ButtonStyle.Light" Text="Cancel" Variant="Variant.Flat" Click="@CancelButtonClick"  />
      </RadzenStack>
    </RadzenTemplateForm>


    </Template>
</RadzenDataList>

"'

cs file :
'"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.JSInterop;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Radzen;
using Radzen.Blazor;

namespace SurgeSurvey.Components.Pages
{
public partial class AddTEvaluer
{
[Inject]
protected IJSRuntime JSRuntime { get; set; }

    [Inject]
    protected NavigationManager NavigationManager { get; set; }

    [Inject]
    protected DialogService DialogService { get; set; }

    [Inject]
    protected TooltipService TooltipService { get; set; }

    [Inject]
    protected ContextMenuService ContextMenuService { get; set; }

    [Inject]
    protected NotificationService NotificationService { get; set; }
    [Inject]
    public SURGE_TESTService SURGE_TESTService { get; set; }

    protected override async Task OnInitializedAsync()
    {
        tEvaluer = new SurgeSurvey.Models.SURGE_TEST.TEvaluer();

        tCriteresForidentifiantCritere = await SURGE_TESTService.GetTCriteres();

        tDeploiersForIdentifiantDeploiement = await SURGE_TESTService.GetTDeploiers();

        tEvaluateurDdsForIdentifiantEvDDS = await SURGE_TESTService.GetTEvaluateurDds();

        tEvaluateurOmsForIdentifiantEvOMS = await SURGE_TESTService.GetTEvaluateurOms();


        
        tEvaluerlist = await SURGE_TESTService.GetTEvaluers();
        tCritere = new SurgeSurvey.Models.SURGE_TEST.TCritere();

    }
    protected bool errorVisible;
    protected SurgeSurvey.Models.SURGE_TEST.TEvaluer tEvaluer;


    protected SurgeSurvey.Models.SURGE_TEST.TCritere tCritere;

    protected IEnumerable<SurgeSurvey.Models.SURGE_TEST.TEvaluer> tEvaluerlist;


    protected IEnumerable<SurgeSurvey.Models.SURGE_TEST.TCritere> tCriteresForidentifiantCritere;

    protected IEnumerable<SurgeSurvey.Models.SURGE_TEST.TDeploier> tDeploiersForIdentifiantDeploiement;

    protected IEnumerable<SurgeSurvey.Models.SURGE_TEST.TEvaluateurDd> tEvaluateurDdsForIdentifiantEvDDS;

    protected IEnumerable<SurgeSurvey.Models.SURGE_TEST.TEvaluateurOm> tEvaluateurOmsForIdentifiantEvOMS;

    [Inject]
    protected SecurityService Security { get; set; }

    protected async Task FormSubmit()
    {
        if (await DialogService.Confirm("Voulez-vous vraiment ajouter cette évaluation ? cool") ==true)
        {
           try
            {
                await SURGE_TESTService.CreateTEvaluer(tEvaluer);
                NavigationManager.NavigateTo("t-evaluers");
            }
            catch (Exception ex)
            {
                //errorVisible = true;
                await DialogService.Alert(ex.Message);
            } 
        }

            
    }

    protected async Task CancelButtonClick(MouseEventArgs args)
    {
        NavigationManager.NavigateTo("t-evaluers");
    }
}

}

'"

Hi @Melcn333,

What seems to be the problem?

I'd like to add new entries in my database using a datalist. I mean, I want to create new datas in DB but for the moment it only update the existing data

You probably need to add new items to a collection and then distinguish between new items and existing ones depending on something. You can check how we have implemented the inline editing demo of RadzenDataGrid for ideas.