locked
Bind textbox to object RRS feed

  • Question

  • User1021841275 posted

    I have a an object (or objects) I want to bind my textboxes to, let's say it's a car with only one possible value, tire1.

    I can bind the value if I don't care about the object, and instead use a variable:

    <input type="text" @bind-value="@StrCarValue" @bind-value:event="oninput" /> then it all works.

    If I instead try to bind to the object, like this

    @foreach (var Car in Cars) {

    <input type="text" @bind-value="@Car.Tire1" @bind-value:event="oninput"  /> then it won't bind. The value in the textbox flips back to 0 (initially set) as soon as I step out of the textbox.

    }

    How can I bind the value Car.Tire1?

    Monday, December 2, 2019 4:33 PM

All replies

  • User1021841275 posted

    Above (simplified) example works as expected, when I break down my code.

    The code binding that doesn't work is embedded in lots of other logic, so that's the culprit, the surrounding code.

    Wednesday, December 4, 2019 9:54 AM