>

Enhanced DropDownListFor

The DropDownListFor Html extension available in the Data Moving Plug-in allows separate styles for each item and grouping of items with the <optgroup> tag. Moreover, the fields working as value and text fields are specified through lambda expressions (thus, taking advantage o syntactic checks and Visual Studio IntelliSense), instead of strings.
Below an example of usage:

 

Html.DropDownListFor(m => m.Roles,
  new {style="height:100px"},
  ChoiceListHelper.CreateGrouped(RegisterModel.AllRoles,
    m => m.Code,
    m => m.Name,
    m => m.GroupCode,
    m => m.GroupName,
    m => new {style="color:White; background-color:Black"},
    m => new { style = m.Code%2 == 0 ?
      "color:Blue; background-color:White":
      "color:Red; background-color:White"} ))

 

The result is:

 

DropDownListFor