protected void RadGridItemAttribute_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is ItemAttributesDetailsViewBO) { ItemAttributesDetailsViewBO objItemAttribute = (ItemAttributesDetailsViewBO)item.DataItem; HtmlAnchor linkEdit = (HtmlAnchor)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objItemAttribute.Attribute.ToString()); LinkButton lbtnEditSUbAttributes = (LinkButton)item.FindControl("lbtnEditSUbAttributes"); lbtnEditSUbAttributes.Attributes.Add("qid", objItemAttribute.Attribute.ToString()); lbtnEditSUbAttributes.Attributes.Add("item", objItemAttribute.ItemID.ToString()); HtmlAnchor linkDelete = (HtmlAnchor)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objItemAttribute.Attribute.ToString()); linkDelete.Visible = (objItemAttribute.IsItemAttributesSubWherethisFabricCode == true) ? false : true; } } }
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 Item Attribute ItemAttributesDetailsViewBO objItemAttribute = new ItemAttributesDetailsViewBO(); // Sort by condition List <ItemAttributesDetailsViewBO> lstItemAttributes = new List <ItemAttributesDetailsViewBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstItemAttributes = (from o in objItemAttribute.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <ItemAttributesDetailsViewBO>() where o.Name.ToLower().Contains(searchText) || ((o.Name.ToLower().Contains(searchText)) || o.Item.ToLower().Contains(searchText)) select o).ToList(); } else { lstItemAttributes = objItemAttribute.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <ItemAttributesDetailsViewBO>(); } /*int sortbyStatus = int.Parse(this.ddlSortBy.SelectedItem.Value); * if (sortbyStatus == 1) * { * lstItemAttributes = (from o in lstItemAttributes * where o.Parent == 0 * select o).ToList(); * } * else if (sortbyStatus == 0) * { * * lstItemAttributes = (from o in lstItemAttributes * where o.Parent > 0 * select o).ToList(); * }*/ if (lstItemAttributes.Count > 0) { this.RadGridItemAttribute.AllowPaging = (lstItemAttributes.Count > this.RadGridItemAttribute.PageSize); this.RadGridItemAttribute.DataSource = lstItemAttributes; this.RadGridItemAttribute.DataBind(); Session["ItemAttributeDetails"] = lstItemAttributes; 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.btnNewAttribute.Visible = false; } this.RadGridItemAttribute.Visible = (lstItemAttributes.Count > 0); }