Template Documentation
DropDownHelperGetDropdownT Method (IEnumerableT, FuncT, String, FuncT, String, FuncT, String, Char, Int32) |
Generate a list of SelectListItem using two attributes of the model as text to display it on the dropdown
Namespace: Template.Web.Commons.Utils
Assembly: Template.Web (in Template.Web.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public static IEnumerable<SelectListItem> GetDropdown<T>( IEnumerable<T> listModel, Func<T, string> key, Func<T, string> firstText, Func<T, string> secondText, char concatCharacter, int selected = 0 )
Parameters
- listModel
- Type: System.Collections.GenericIEnumerableT
The list source of the model - key
- Type: SystemFuncT, String
A function to get the property of the model to use as a key of the dropdown - firstText
- Type: SystemFuncT, String
A function to get the property of the model to use as the first part of the text of the dropdown - secondText
- Type: SystemFuncT, String
A function to get the property of the model to use as the second part of the text of the dropdown - concatCharacter
- Type: SystemChar
A character to concat both text as one to display it on the dropdown - selected (Optional)
- Type: SystemInt32
Index of which element whatns to be selected of the begining, default 0
Type Parameters
- T
- The Model type for generate the list
Return Value
Type: IEnumerableSelectListItemA list of SelectedListItem ready to use as a source of a dropdown with Razor
See Also