0

I am unable to configure a select dropdown to display the value of the model property. I am working from scaffolded pages where i need to use a different control than what the scaffolder chose.

I am trying to create a boolean dropdown capable of handling true, false, null for display and edit.

This line of code shows the correct value of True on the edit page.

 <p>@Job.IsActive</p>

This block of code shows Null which is incorrect. I thought asp-for created the binding between the model class and the html/ui.

        <div class="mb-3">
            <label for="isactive" class="form-label">Is Active:</label>
            <select id="isactive" asp-for="@Job.IsActive" class="form-select">
                <option value="Null">Null</option>
                <option value="False">No</option>
                <option value="True">Yes</option>
            </select>
        </div>

Job is the entity class for the Job table and in this case is properly populated. I am sure that the Null bit is wrong, but the main goal is to select and show the value of Job.IsActive. I have tried many variations with and without quotes, @, attributes, bind-Value, and more.

ps - after further research i discovered that i am working under the blazor arrangement - if i understand correctly. ie i used the default aspire project which uses .razor files and .razor components. i don't have cshtml pages. not exactly sure how that changes things, but it seems worth noting.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.