hi
view
@Html.DropDownListFor(model => model.RoleId, (IEnumerable<SelectListItem>)MvcApplicationIntranetApplication.Helpres.GenricHelpers.GetRolesList(), "--Select Roles --", new { @class = "required" })
helper class code:-
public static SelectList GetRolesList()
{
try
{
using (TestDBEntities db = new TestDBEntities())
{
List<Role> roleList = (from roles in db.Roles
select roles).ToList<Role>();
return new SelectList(roleList, "Id", "RoleName");
}
}
catch (SqlException)
{
return null;
}
catch (EntityException)
{
return null;
}
}
PLease mark if it work for you