We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Textboxes not populating

I have a page with a datagrid that has several records. I have added a command column that has a custom button. The button navigates to a details page for the selected record. On the details page, I have the page directive set as :  @page "/details/{Id:int}"
In the @code section I have a parameter:  public int Id { get; set;}
When I have only one textbox, it populates fine. But when I add additional textboxes for the rest of the fields, none of the boxes are populated.

     public int Id { get; set;}
     Contact contact = new Contact();

     protected override async Task OnInitializedAsync()
        contact = await contactService.GetContactByIdAsync(Id);

That is how my code looks in the details page. Each textbox is bound by using:  @bind-Value="@contact.FirstName", with their respective field names.
With a single textbox, it works. When I add additional textboxes, nothing populates.

Please help


1 Reply

NP Narayanasamy Panneer Selvam Syncfusion Team October 31, 2019 02:16 PM UTC

Hi Michael, 

Greetings from Syncfusion support. 

We have validated your problem in the reported use case scenario. We suspect that you may set same ID to the TextBoxComponents. So, the probability that you may get overlapping of textbox components or getting updated value in first textbox. 
So kindly use different ID for each component rendering. 
Code example: 
<EjsTextBox ID="@("text" + Id.ToString())" @bind-Value="@name"></EjsTextBox> 
<EjsTextBox ID="@("text1" + Id.ToString())" @bind-Value="@name"></EjsTextBox> 
<EjsTextBox ID="@("text2" + Id.ToString())" @bind-Value="@name"></EjsTextBox> 
    public int Id { get; set; } 
    public string name { get; set; } 
    protected override async Task OnInitializedAsync() 
        name = await ForecastService.GetForecastAsync(Id); 

For your convenience we have prepared a sample with reported scenario.

Demo sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/TextBox_route-2129771936

Narayanasamy P.

Live Chat Icon For mobile
Up arrow icon