问题描述
我有一个选择列表我在一个视图模型和DropDownFor已经设置,它已经拥有了自己下令如u可以看到下面,但我需要它来过滤,使第3列退休,如果它的值为0的所有这些结果示但如果它是1。
我想我需要的.OrderBy(...)。之后加入其中(M => m.Retired但不知道我究竟从那里将其过滤和OFC它没有在虚拟机中执行,但这只是我如何能够实现排序依据的过滤器。
VM
列表<原因> reasonList = _db.Reasons.OrderBy(M => m.Description).ToList();
ReasonList =新的SelectList(reasonList,ID,说明);
DDF
<%:Html.DropDownListFor(M = GT; m.amwrAudit.AppTherRea,Model.ReasonList,--------------- -------选择一个原因---------------------)%>
您是否在寻找
。凡(M = GT;!m.Retired)
。因为它是一个布尔值,不需要等号。
如果您不方便与语法,你仍然可以键入。凡(M = GT; m.Retired == FALSE)
I have a selectlist which I've setup in a ViewModel and DropDownFor and it already has itself ordered as u can see below but I need it to filter so that the 3rd column "Retired" if it's value is "0" all those results are show but not if it's "1".
I was thinking I would need to add after the .OrderBy(...).Where(m=>m.Retired but don't know how exactly I'd filter it from there and ofc it doesn't have to be done in the VM but that's just how I was able to implement the OrderBy filter.
VM
List<Reason> reasonList = _db.Reasons.OrderBy(m=>m.Description).ToList();
ReasonList = new SelectList(reasonList, "Id", "Description");
DDF
<%: Html.DropDownListFor(m => m.amwrAudit.AppTherRea, Model.ReasonList, "---------------------- Select a Reason ---------------------")%>
Are you looking for
.Where(m=>!m.Retired)
. Because it is a bool, no equal signs are needed.
If you are uncomfortable with that syntax you can still type .Where(m=>m.Retired == false)
这篇关于的SelectList基于&QUOT SQL表列布尔筛选结果;退休&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!