0
<div class="form-group">
        <label>Quoted With New Combo Endorsement</label>
        @Html.DropDownListFor(a => a.Quoted_With_New_Combo_Endorsement, new[]
        {
            new SelectListItem {Text = "Yes", Value = "Yes"},
            new SelectListItem {Text = "No", Value = "No"},

        }, "Select the Value", new { style = "width:250px", @class = "form-control" })
    </div>

How to convert this code to the checkbox for(Yes/NO)?

Reminder: datatype can't be changed to bool

2 Answers 2

1

I've done this in a project and it's working fine.

<div class="form-group">
    <label class="col-md-2 control-label">Scan in Colour?</label>
    <div class="col-md-10">
        <div class="radio-group">
            @Html.RadioButtonFor(m => m.ScanInColour, "Yes", 
              new { @id = "ScanInColourYes", @class = "form-control" })
            <span>Yes</span>
            @Html.RadioButtonFor(m => m.ScanInColour, "No", 
              new { @id = "ScanInColourNo", @class = "form-control" })
            <span>No</span>
        </div>
    </div>
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

Shouldn't it be a radio-button because it either yes or no?

Instead of the @Html.DropDownListFor use:

@Html.RadioButton("YesNo","Yes")  
@Html.RadioButton("YesNo","No") 

Comments

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.