I'm currently populating my drop downlists like this...  public  List<NewLogin> GetRolesForDDL()    {        using (database db = new database())        {            return (from r in db.UserRole                    select new NewLogin                    {                        UserRole = r.Role,                        RoleID = r.RoleID                    }).ToList();        }    }        public  NewLogin RoleDDL()    {        NewLogin nl = new NewLogin();        using (database db = new database())        {                               // populates ddl            nl.RoleList = new SelectList(GetRolesForDDL(), RoleID, UserRole);                        }        return nl;    }The part I don't like in particular is where nl.RoleList = new SelectList(GetRolesForDDL()Is there a better way I can do this, by keeping within the same style and bypassing that method and using a quick and easy lambda expression instead?Also another quick question is...@Html.DropDownListFor(u => u.RoleID, Model.RoleList)When I pass this to the controller I get the RoleID value, but my RoleName(text of ddl)get's passed as null. Can I access both RoleName and ID without fetching it in the backend?I know this doesn't work, but I'm thinking it would have to be something like DDLFor(u => u.RoleID, u.RoleName)
Improving MVC 4 DropDownList
c#;linq;asp.net mvc 4
Can I access both RoleName and ID without fetching it in the backend?Yes, I believe so if you want to write a bit of javascript.  You would need to create a hidden field and on every select list change event set the value of that field.Something like$(body).on(change, #selectbox, function() {    $(#inputbox).val($(this).val());});I'm also unsure as to why you are creating the database connection twice but I would considerpassing that into the GetRoles method like so:public  IEnumerable<NewLogin> GetRolesForDDL(database db){    return (from r in db.UserRole            select new NewLogin            {                UserRole = r.Role,                RoleID = r.RoleID            });     }    public  NewLogin RoleDDL(){    using (database db = new database())    {                                       var roles = GetRolesForDDL(db).ToList();        // populates ddl        return new NewLogin        {            RoleList = new SelectList(roles, RoleID, UserRole);                        }    }}Or even if both of these methods are part of a class consider passing the database into the class constructor and using it as a private instance variable.