html – Razor checkbox is not rendering existing value

Checkbox works totally fine when saving the value, it persists properly, 1 for true 0 for false in database. When clicked it toggles perfectly between checked and unchecked state. It however, doesn’t reflect the true/checked state on UI when trying to edit that model object. I have tried

  1. Auto generated Razor View by Visual Studio

        <div class="form-group">
            <div class="checkbox">
                <label>
                    <input asp-for="OnSale" /> @Html.DisplayNameFor(model => model.OnSale)
                </label>
            </div>
        </div>
    
  2. By input tag

        <div class="form-group">
            <input asp-for="OnSale" />
        </div>
    

    also

        <div class="form-group">
            <input type="checkbox" asp-for="OnSale" />
        </div>
    

    and this as well

        <div class="form-group">
            <input type="checkbox" asp-for="OnSale" checked="@(Model.OnSale == true ? "checked" : "")"/>
        </div>
    

    This approach shows checked state even for unchecked or new object.

  3. By @Html notation

    @Html.CheckBoxFor(model => model.OnSale)

None of the above seem to work, they do not display true state on edit mode.