@model IList @{ object attributes; if (ViewBag.Disabled == true) { attributes = new { @class = "form-control formultiselect2", @disabled = "disabled" }; } else { attributes = new { @class = "form-control formultiselect2" }; } } @Html.DropDownList(string.Empty, (IList)ViewData["List"], attributes)