private void PopulateDataGrid() { // Hide Controls this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Category CategoryBO objCategory = new CategoryBO(); List <CategoryBO> lstCategory = new List <CategoryBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstCategory = (from o in objCategory.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) || (o.Description != null ? o.Description.ToLower().Contains(searchText) : false) select o).ToList(); } else { lstCategory = objCategory.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstCategory.Count > 0) { this.RadGridCategories.AllowPaging = (lstCategory.Count > this.RadGridCategories.PageSize); this.RadGridCategories.DataSource = lstCategory; this.RadGridCategories.DataBind(); Session["CategoriesDetails"] = lstCategory; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search")) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; this.btnAddCategories.Visible = false; } this.RadGridCategories.Visible = (lstCategory.Count > 0); }