Cannot bind SfTextbox to double?

I have a class defined as follows:


 public class Job

 {

     public int Id { get; set; }

     public string Name { get; set; }

     public string? Address { get; set; }

     public string? City { get; set; }

     public string? State { get; set; }

     public string? ZIP { get; set; }

     public double? Lat { get; set; }

     public double? Long { get; set; }

     public string? SpecialNotes { get; set; }

     public DateTime? FinalizedDate { get; set; }

     public string? Image { get; set; }

     public string? Document { get; set; }

     public string? Document2 { get; set; }

     public string? Document3 { get; set; }

     public string? JobType { get; set; }

     public DateTime? Created { get; set; }

     public DateTime? Updated { get; set; }

     public int Creator { get; set; }

 }


When I try to bind the Lat property to the SfTextbox, I receive an error stating that I cannot convert a double? to a string.

I tried using the SfNumericTextbox but need events to be triggered. The SfNumericTextbox would not fire the ValueChange event that is required or additional code to run. 


Am I missing something?


Thanks!


1 Reply

KP Kokila Poovendran Syncfusion Team November 13, 2023 11:35 AM UTC

Hi Michael,


Thank you for reaching out to us with your concern about binding the Lat property of type double? to the SfTextBox component.


Upon reviewing your class definition and the reported issue, it appears that the SfTextBox component supports only the string type for binding, which explains the error you are encountering when attempting to bind a double?.


API https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.TextBoxModel.html#Syncfusion_Blazor_Inputs_TextBoxModel_Value


To address this, we recommend using the SfNumericTextBox, which is designed for numeric input. Regarding your mention of the ValueChange event not triggering as expected, we have tested it at our end, and it appears to be working correctly.


We have prepared a sample that demonstrates the usage of SfNumericTextBox with the ValueChange event. You can find the sample bellow attachment. Please review it, and if you encounter any issues or need further assistance, feel free to modify the provided sample to replicate the problem.


If you have additional details about your scenario or encounter any specific challenges, please provide more information, and we will do our best to assist you promptly.


Thank you for your understanding, and we look forward to resolving this matter to your satisfaction.


Regards,

Kokila Poovendran.


Attachment: BlazorServerProject_c9f2260c.zip

Loader.
Up arrow icon