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 SupplierDetailsViewBO objSupplier = new SupplierDetailsViewBO(); List <SupplierDetailsViewBO> lstSuplliers = new List <SupplierDetailsViewBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstSuplliers = (from o in objSupplier.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where o.Name.ToLower().Contains(searchText) || o.Country.ToLower().Contains(searchText) select o).ToList(); } else { lstSuplliers = objSupplier.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstSuplliers.Count > 0) { this.RadGridSuppliers.AllowPaging = (lstSuplliers.Count > this.RadGridSuppliers.PageSize); this.RadGridSuppliers.DataSource = lstSuplliers; this.RadGridSuppliers.DataBind(); Session["SupplierDetails"] = lstSuplliers; 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.btnAddSupplier.Visible = false; } this.RadGridSuppliers.Visible = (lstSuplliers.Count > 0); } }
protected void RadGridSuppliers_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is SupplierDetailsViewBO) { SupplierDetailsViewBO objSupplier = (SupplierDetailsViewBO)item.DataItem; Label lblCountry = (Label)item.FindControl("lblCountry"); lblCountry.Text = objSupplier.CountryID.ToString(); HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objSupplier.Supplier.ToString()); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objSupplier.Supplier.ToString()); linkDelete.Visible = (objSupplier.IsAccessoriesWherethisSupplier == true && objSupplier.IsFabricCodesWherethisSupplier == true) ? false : true; } } }