public PartialViewResult IndexPartialView(int?UserId, string SearchString, int?currentPageIndex) { var ctx = new SmsContext(); if (string.IsNullOrEmpty(SearchString)) { SearchString = string.Empty; UserId = 0; } var list = ctx.SP_GET_ALL_ROLE(Convert.ToInt32(UserId), SearchString).Take(SystemConstant.MAX_ROWS).ToList <SP_GET_ALL_ROLE_Result>(); RoleModel model = new RoleModel(); int pageSize = SystemConstant.ROWS; int pageIndex = currentPageIndex == null ? 1 : (int)currentPageIndex; model.RoleList = list.ToPagedList(pageIndex, pageSize); ViewBag.SearchString = SearchString; model.PageCount = list.Count; ctx.Dispose(); return(PartialView("IndexPartialView", model)); }