I'm using the Html.DropDownListFor()
to display a dropdown with data from a list. The list items have a boolean property called IsPublic
, defining whether this item is public or not.
Here's how I define the dropdown:
@Html.DropDownListFor(m => m.SelectedLayout,
new SelectList(Model.Layout, "LayoutString", "LayoutName", "IsPublic", 1))
As you can see, I'm grouping by the property IsPublic
. As expected, the grouping is done the following way, with the following naming of the groups:
Notice how the grouping is done by the boolean value (true
and false
).
Is there a way for me to display this grouping as a custom string, though still grouping on the boolean value? So if IsPublic == true
display the grouping name as Public
and vice versa IsPublic == false
display grouping name as Private
?