How to sort the dropdownlist?

0

How can I sort the DropdownList ?

        <div class="form-group">
            @Html.LabelFor(model => model.id_pessoa, "Pessoa", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("id_pessoa", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.id_pessoa, "", new { @class = "text-danger" })
            </div>
        </div>
    
asked by anonymous 18.06.2017 / 16:27

1 answer

1

In the control where you create the list, you need to use .OrderByDescending() or OrderBy() and put the field you would like using the expression.

See more in this question: link

    
05.07.2017 / 15:51