0
我想根據用戶是否登錄,有條件地隱藏EnumDropDownListFor
中的元素。EnumDropDownListFor有條件地隱藏項目
枚舉
public enum SortType
{
[Display(ResourceType = typeof(NavigationItems), Name = "BestMatch")]
Best_Match = 0,
[Display(ResourceType = typeof(NavigationItems), Name = "Alphabetical")]
Alphabetical,
[Display(ResourceType = typeof(NavigationItems), Name = "PriceAsc")]
PriceAsc,
[Display(ResourceType = typeof(NavigationItems), Name = "PriceDesc")]
PriceDesc
}
我期待隱藏項目PriceAsc
& PriceDesc
我試圖尋找到AutoGenerateFilter
和AutoGenerateField
性能無濟於事。
查看
@Html.EnumDropDownListFor(x => x.sortType, new { id = "orderResults" })
如何拆解,檢查user.identity.isauthenticated的EnumDropDownListFor並實現自定義的幫手? – heymega
這是我以前如何做到這一點,我希望有一些不錯的MVC 5.1方法做到這一點:) –
你可以在這裏找到解決方案http://stackoverflow.com/questions/27133014/exclude-remove-value - 從-MVC-5-1-enumdropdownlistfor –