public ActionResult Update(ApplicationUser _user) { //The model is valid - update the product and redisplay the grid. using (var ctx = new ApplicationDbContext()) { ApplicationUser user = new ApplicationUser(); user = ctx.Users.Where(x => x.Id == _user.Id).FirstOrDefault(); if (user != null) { user.FirstName = _user.FirstName; user.LastName = _user.LastName; user.Status = _user.Status; user.UserRole = _user.UserRole; user.MobileNo = _user.MobileNo; } var Usermanager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); string Existinguserrole = string.Empty; Existinguserrole = Commonhelper.Rolename(_user.UserRole); Usermanager.RemoveFromRole(user.Id, Existinguserrole); Usermanager.AddToRole(user.Id, _user.UserRoleName); ctx.Entry(user).State = EntityState.Modified; ctx.SaveChanges(); } //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. RouteValueDictionary routeValues = this.GridRouteValues(); return(RedirectToAction("RegisteredAccounts")); }