In my Blazor project, I have a simple input textbox where I want to bind to a product price value. The price is initially calculated as:
PackageObject.Price = PackageObject.PackageProducts.Sum(x => x.Product.Price * x.Qty);
Then I bind the variable to the textbox:
<input class="form-control" type="text" @bind="@PackageObject.Price" placeholder="Package Price" />
The goal here is to set the initial value as the calculated value but then allow user to change it using the textbox.
However, I am not able to change the value at all! Say the calculated price is 800 and I want to change it to whatever else, it immediately change the value back to 800!
I assume because of the calculation, it's tied to the objects. Without changing the objects' own underlying pricing, this calculated price will always reflect what the calculation does. But I've then change it to use a variable like;
var price = PackageObject.PackageProducts.Sum(x => x.Product.Price * x.Qty);
I then bind the variable @price to the textbox, same thing. I couldn't figure out a way by setting the textbox with my initially calculated value and then let user change it as needed.
Help please.
Thanks!
Frank