0

How can convert from Select drop list to RadioButton ?

This is my code code to render a select drop list.

<div class="form-group">
    @Html.LabelFor(model => model.Unit, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.Unit, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.Unit, "", new { @class = "text-danger" })
    </div>
</div>

This is my result

enter image description here

The result on my Database is: null [Not Set], 0[false], 1 [true]

The Html Result is:

    <div class="form-group">
        <label class="control-label col-md-2" for="Laptop">Laptop</label>
        <div class="col-md-10">
            <div class="checkbox">
                <select class="list-box tri-state" id="Laptop" name="Laptop"><option selected="selected" value="">Not Set</option>
<option value="true">True</option>
<option value="false">False</option>
</select>
                <span class="field-validation-valid text-danger" data-valmsg-for="Laptop" data-valmsg-replace="true"></span>
            </div>
        </div>
    </div>
Alex
  • 727
  • 1
  • 13
  • 32

0 Answers0