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 Items OrderTypeBO objOrderType = new OrderTypeBO(); // Sort by condition //int sortbyStatus = int.Parse(this.ddlSortBy.SelectedItem.Value); //if (sortbyStatus < 2) //{ // //objItem.IsActive = Convert.ToBoolean(sortbyStatus); //} List <OrderTypeBO> lstOrderType = new List <OrderTypeBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstOrderType = (from o in objOrderType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) || o.Description.ToLower().Contains(searchText) select o).ToList(); } else { lstOrderType = objOrderType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstOrderType.Count > 0) { this.RadGridOrderTypes.AllowPaging = (lstOrderType.Count > this.RadGridOrderTypes.PageSize); this.RadGridOrderTypes.DataSource = lstOrderType; this.RadGridOrderTypes.DataBind(); Session["OrderTypesDetails"] = lstOrderType; 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.btnAddOrderType.Visible = false; } this.RadGridOrderTypes.Visible = (lstOrderType.Count > 0); } }