gpt4 book ai didi

c# - 如何对@Html.DropDownListFor 进行排序?

转载 作者:太空宇宙 更新时间:2023-11-03 17:54:15 25 4
gpt4 key购买 nike

我想在 MVC C# 中对下拉列表进行排序。这是我的下拉列表。所以我想按“FULLNAME”排序。

@Html.DropDownListFor(c => c.t_PEOPLE, 
new SelectList(Model.PEOPLE,
"KEY",
"FULLNAME",
Model.BOTKEY),
new {onchange = "BusinessContact(this.value);" })

我该怎么做?

最佳答案

/* other code here.. */
new SelectList(Model.PEOPLE.OrderBy(x => x.FirstName),
// ^^^^^^^^^^^^^^^^^^^^^^^ this
/* rest of the code here */

关于c# - 如何对@Html.DropDownListFor 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15800308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com