private void FillResourceGrid() { string searchText = txtSearchText.Text.Trim(); int totalRecords = 0; int fetchedRecords = _pageSize * ResourceTable.PageIndex; ResourceTable.PageSize = _pageSize; List <Resource> resourceList = new List <Resource>(); using (ResourceDataAccess dataAccess = new ResourceDataAccess(Utility.CreateContext())) { IEnumerable <Resource> resources = null; if (!rbSearchOptions.SelectedItem.Text.Equals(Resources.Resources.SearchInExistingList)) { resources = dataAccess.GetResources(searchText); } else { resources = dataAccess.GetResourcesWithExplicitPermissions(Id, searchText, userToken); } resourceList = resources.OrderBy(tuple => tuple.Title).Skip(fetchedRecords).Take(_pageSize).ToList(); totalRecords = resources.Count(); Utility.UpdateResourcesEmptyTitle(resourceList); } if (!(totalRecords > 0)) { lblErrorResourcePermission.Text = Resources.Resources.NoRecordsFound; lblErrorResourcePermission.ForeColor = System.Drawing.Color.Red; lblErrorResourcePermission.Visible = true; } if (resourceList != null) { //Update page count UpdatePageCount(ResourceTable, totalRecords); if (resourceList.Count > 0) { ResourceTable.DataSource = resourceList; ResourceTable.DataBind(); } } }