public ActionResult PostMember(LoginViewModel model) { using (ProjectEntities db = new ProjectEntities()) { if (ModelState.IsValid) { var member = db.MemberLogins.SingleOrDefault(a => a.EmailId == model.EmailId); if (member == null) { db.InsertMember(model.EmailId, model.Password, model.RoleId); ViewBag.Message = "Registration Successsfull"; } else { ViewBag.Message = "EmailID Already Exists"; } } else { ViewBag.Message = "Invalid Input"; } } List <SelectListItem> lst = new List <SelectListItem>(); using (ProjectEntities db = new ProjectEntities()) { var getdata = db.RoleDetails.ToList(); foreach (var item in getdata) { lst.Add(new SelectListItem { Value = item.RoleId.ToString(), Text = item.RoleName }); } } LoginViewModel model1 = new LoginViewModel(); model1.RoleName = lst; return(View("Register", model1)); }