private void PopulateDataGrid() { this.dvDataContent.Visible = false; this.dvEmptyContent.Visible = false; this.dvNoSearchResult.Visible = false; string searchText = this.txtSearch.Text.ToLower().Trim(); PrinterTypeBO objPrinterType = new PrinterTypeBO(); List <PrinterTypeBO> lstPrinterType = new List <PrinterTypeBO>(); if (txtSearch.Text != string.Empty && txtSearch.Text != "search") { lstPrinterType = (from pt in objPrinterType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() where pt.Name.ToLower().Contains(searchText)/*|| * pt.Description.ToLower().Contains(searchText)*/ select pt).ToList(); } else { lstPrinterType = objPrinterType.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); } if (lstPrinterType.Count > 0) { this.RadGridPrinterType.AllowPaging = (lstPrinterType.Count > this.RadGridPrinterType.PageSize); this.RadGridPrinterType.DataSource = lstPrinterType; this.RadGridPrinterType.DataBind(); Session["PrinterTypeDetails"] = lstPrinterType; 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.btnAddPrinterType.Visible = false; } this.RadGridPrinterType.Visible = (lstPrinterType.Count > 0); }
protected void RadGridPrinterType_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is PrinterTypeBO) { PrinterTypeBO objPrinterType = (PrinterTypeBO)item.DataItem; HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); linkEdit.Attributes.Add("qid", objPrinterType.ID.ToString()); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objPrinterType.ID.ToString()); linkDelete.Visible = (objPrinterType.PatternsWhereThisIsPrinterType.Count == 0) ? true : false; } } }
private void ProcessForm(int printertypeId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { PrinterTypeBO objPrinterType = new PrinterTypeBO(this.ObjContext); if (printertypeId > 0) { objPrinterType.ID = printertypeId; objPrinterType.GetObject(); //Update objPrinterType.Name = this.txtPrinterTypeName.Text; //** objPrinterType.Description = this.txtDescription.Text; //btn_Delete if (isDelete) { objPrinterType.Delete(); } } else { //Add New details objPrinterType.Name = this.txtPrinterTypeName.Text; //**objPrinterType.Description = this.txtDescription.Text; objPrinterType.Add(); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { //throw ex; } }