public ActionResult Getuser(int fId) { List <SelectListItem> userItems = new List <SelectListItem>(); TblUser sessionUser = (TblUser)Session["UserSession"]; var Users = userRepository.GetAllUsers(sessionUser.TenantId); foreach (var user in Users) { userItems.Add(new SelectListItem { Text = Convert.ToString(user.FirstName + " " + user.LastName), Value = Convert.ToString(user.UserId) }); } DataSet ds = fr.GetAssignedForumUsers(fId); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { foreach (var item in userItems) { DataRow[] foundUsers = ds.Tables[0].Select("UserId = " + item.Value + ""); if (foundUsers.Length != 0) { item.Selected = true; } } } } } return(Json(userItems, JsonRequestBehavior.AllowGet)); }