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 ItemBO objSubItem = new ItemBO(); // Sort by condition int sortbyStatus = int.Parse(this.ddlSortBy.SelectedItem.Value); if (sortbyStatus < 2) { //objItem.IsActive = Convert.ToBoolean(sortbyStatus); } List <ItemBO> lstSubItems = new List <ItemBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstSubItems = (from o in objSubItem.SearchObjects().ToList() where o.Name.ToLower().Contains(searchText) select o).ToList(); } else { lstSubItems = objSubItem.SearchObjects().ToList(); } if (lstSubItems.Count > 0) { this.dgItemSubCategory.AllowPaging = (lstSubItems.Count > this.dgItemSubCategory.PageSize); this.dgItemSubCategory.DataSource = lstSubItems; this.dgItemSubCategory.DataBind(); this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search") || (sortbyStatus < 2)) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty) + "Sort by " + this.ddlSortBy.SelectedItem.Text; this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; } this.lblSerchKey.Text = string.Empty; this.dgItemSubCategory.Visible = (lstSubItems.Count > 0); }
private void PopulateSubItems(bool addNewRecorde, int editItemIndex, int currentPateIndex) { if (this.IsNotRefresh) { this.dgAddEditSubItem.CurrentPageIndex = currentPateIndex; this.dgAddEditSubItem.EditItemIndex = editItemIndex; ItemBO obj = new ItemBO(); obj.Parent = int.Parse(this.ddlParentAttribute.SelectedValue.ToString()); List <ItemBO> lstEmptyList = obj.SearchObjects().OrderBy(o => o.Name).ToList(); if (addNewRecorde || lstEmptyList.Count == 0) { ItemBO objItem = new ItemBO(); objItem.ID = 0; objItem.Parent = int.Parse(this.ddlParentAttribute.SelectedValue.ToString()); objItem.Name = string.Empty; objItem.Description = string.Empty; lstEmptyList.Insert(0, objItem); if (dgAddEditSubItem.CurrentPageIndex > Math.Floor((double)(lstEmptyList.Count / dgAddEditSubItem.PageSize))) { dgAddEditSubItem.CurrentPageIndex = Convert.ToInt32(Math.Floor((double)(lstEmptyList.Count / dgAddEditSubItem.PageSize))); } this.dgAddEditSubItem.EditItemIndex = 0;//lstEmptyList.Count - 1; } this.dgAddEditSubItem.DataSource = lstEmptyList; //this.dgAddEditSizes.AllowPaging = (lstEmptyList.Count > dgAddEditSizes.PageSize); this.dgAddEditSubItem.DataBind(); ViewState["IsPopulateSubItemModel"] = true; ViewState["IsPopulateItemModel"] = false; } else { ViewState["IsPopulateSubItemModel"] = false; ViewState["IsPopulateItemModel"] = false; } }
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 ItemBO objItem = new ItemBO(); List <ItemBO> lstItems = new List <ItemBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstItems = (from o in objItem.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) && (o.Parent == 0) select o).ToList(); //lstItems = objItem.SearchObjects().AsQueryable().OrderBy(SortExpression).Where(o => o.Parent == 0 && o.Name.ToLower().Contains(searchText)).ToList(); } else { lstItems = objItem.SearchObjects().AsQueryable().OrderBy(SortExpression).Where(o => o.Parent == 0).ToList(); } // Sort by condition //int sortbyStatus = int.Parse(this.ddlSortBy.SelectedItem.Value); //if (sortbyStatus == 1) //{ // lstItems = (from o in lstItems // where o.Parent == 0 // select o).ToList(); //} //else if (sortbyStatus == 0) //{ // lstItems = (from o in lstItems // where o.Parent > 0 // select o).ToList(); //} if (lstItems.Count > 0) { this.RadGridItems.AllowPaging = (lstItems.Count > this.RadGridItems.PageSize); this.RadGridItems.DataSource = lstItems; this.RadGridItems.DataBind(); Session["ItemsDetails"] = lstItems; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search") /*|| (sortbyStatus < 2)*/) { //this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty) + "Filter by " + this.ddlSortBy.SelectedItem.Text; this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; this.btnAddItem.Visible = false; } ViewState["IsPopulateSubItemModel"] = false; ViewState["IsPopulateItemModel"] = false; this.RadGridItems.Visible = (lstItems.Count > 0); }