0

I want to show that if data does not exist then the dropdown will work normally but when the data exist then the drop-down will be disabled. I tried read-only but it is also not working for dropdown while it is working for the textbox.

@if (TrimsDataForEdit != null)
{
    <div class="form-group">
        @Html.LabelFor(m => m.SeasonId, new { @class = "col-lg-4 control-label" })
        <div class="col-lg-7">
            @Html.DropDownListFor(m => m.SeasonId, ViewBag.SeasonDDList as SelectList, new { @class = "form-control custom-select-box", @readonly = "readonly" })
            @Html.ValidationMessageFor(m => m.SeasonId, "", new { @class = "text-danger" })
        </div>
        <div class="col-lg-1">
            <span class="required">*</span>
        </div>
    </div>

}
else
{
    <div class="form-group">
        @Html.LabelFor(m => m.SeasonId, new { @class = "col-lg-4 control-label" })
        <div class="col-lg-7">
            @Html.DropDownListFor(m => m.SeasonId, ViewBag.SeasonDDList as SelectList, new { @class = "form-control custom-select-box" })
            @Html.ValidationMessageFor(m => m.SeasonId, "", new { @class = "text-danger" })
        </div>
        <div class="col-lg-1">
            <span class="required">*</span>
        </div>
    </div>

}
Nkosi
  • 235,767
  • 35
  • 427
  • 472
Nabid
  • 197
  • 5
  • 24
  • You could disable dropdown with adding **new { disabled = "disabled" }** attribute – Angel Dinev Dec 01 '18 at 10:18
  • @AngelD I used that but when the field is disabled the other fields of that form does not update when I update the whole form except the disabled ones! – Nabid Dec 01 '18 at 10:41

0 Answers0