protected void gridViewProductDetail_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { try { ASPxCheckBox checkBox = gridViewProductDetail.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "chkProductDetail") as ASPxCheckBox; if (checkBox != null) { if (e.DataColumn.FieldName == "is_selected") { if (productDetailList != null) { var row = (from t in productDetailList where t.product_no == Convert.ToString(e.KeyValue) select t).FirstOrDefault(); if (row != null) { checkBox.Checked = row.is_selected; } } //checkBox.Checked = (row["is_selected"]) == DBNull.Value ? false : true; } } } catch (Exception ex) { throw ex; } }
protected void MailFileGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "Status" && (e.CellValue.ToString() == "OK" || e.CellValue.ToString() == "Scanning")) { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Scanned") { e.Cell.BackColor = System.Drawing.Color.FromName("#87CEEB"); e.Cell.ForeColor = System.Drawing.Color.Black; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "disabled") { e.Cell.BackColor = System.Drawing.Color.Gray; // e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status") { e.Cell.BackColor = System.Drawing.Color.Yellow; // e.DataColumn.GroupFooterCellStyle.ForeColor = } }
protected void TaxTypeGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "TaxTypeId") { e.Cell.Attributes.Add("onclick", "event.cancelBubble = true"); } }
protected void EXJournalGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { ASPxGridView gv = sender as ASPxGridView; Label hfStatus = gv.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "hfNameLabel") as Label; if (e.DataColumn.FieldName == "Status" && (hfStatus.Text.ToString() == "OK" || hfStatus.Text.ToString() == "Scanning" || hfStatus.Text.ToString() == "Telnet")) { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Not Scanned") { e.Cell.BackColor = System.Drawing.Color.FromName("#87CEEB"); e.Cell.ForeColor = System.Drawing.Color.Black; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Disabled") { e.Cell.BackColor = System.Drawing.Color.FromName("#D0D0D0"); } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Maintenance") { e.Cell.BackColor = System.Drawing.Color.LightBlue; } else if (e.DataColumn.FieldName == "Status") { e.Cell.BackColor = System.Drawing.Color.Yellow; } }
protected void Grid_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { e.Cell.HorizontalAlign = HorizontalAlign.Center; if (cellColumnSpans.ContainsKey(e.Cell)) { e.Cell.ColumnSpan = cellColumnSpans[e.Cell]; e.Cell.BackColor = System.Drawing.Color.LightYellow; } }
protected void EXJournalGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { ASPxGridView gv = sender as ASPxGridView; Label hfStatus = gv.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "hfNameLabel") as Label; //10/4/2013 NS added Label hfExTotal = gv.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "hfExTotalLabel") as Label; string ExJournalThreshold = "1000"; try { ExJournalThreshold = VSWebBL.SettingBL.SettingsBL.Ins.Getvalue("ExJournal Threshold"); } catch (Exception ex) { Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } if (e.DataColumn.FieldName == "EXTotal" && ExJournalThreshold != "") { if (Convert.ToInt32(hfExTotal.Text.ToString()) > Convert.ToInt32(ExJournalThreshold)) { e.Cell.ForeColor = System.Drawing.Color.Red; } } if (e.DataColumn.FieldName == "Status" && (hfStatus.Text.ToString() == "OK" || hfStatus.Text.ToString() == "Scanning" || hfStatus.Text.ToString() == "Telnet")) { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Not Scanned") { e.Cell.BackColor = System.Drawing.Color.FromName("#87CEEB"); e.Cell.ForeColor = System.Drawing.Color.Black; } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Disabled") { e.Cell.BackColor = System.Drawing.Color.FromName("#D0D0D0"); } else if (e.DataColumn.FieldName == "Status" && hfStatus.Text.ToString() == "Maintenance") { e.Cell.BackColor = System.Drawing.Color.LightBlue; } else if (e.DataColumn.FieldName == "Status") { e.Cell.BackColor = System.Drawing.Color.Yellow; } }
protected void ServicesGrid_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "Result" && (e.CellValue.ToString() == "Running")) { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "Result" && (e.CellValue.ToString() == "Stopped")) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Result") { e.Cell.BackColor = System.Drawing.Color.Yellow; } }
protected void gv_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.VisibleIndex >= 0) { string fieldName = e.DataColumn.FieldName; if (fieldName == "score") { var score = Utils.ConvertToNullableDecimal(e.CellValue); if (score != null) { e.Cell.BackColor = (score >= OkNokTreshold) ? ColorOK : ColorNOK; e.Cell.Text = $"{Math.Floor((decimal)score)} %"; } } } }
protected void gvMain_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "SlaResponse") { if (e.CellValue.ToString() == "NO OK") { //e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.Red; } } if (e.DataColumn.FieldName == "SlaResolution") { if (e.CellValue.ToString() == "NO OK") { //e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.Red; } } if (e.DataColumn.FieldName == "SlaRestoration") { if (e.CellValue.ToString() == "NO OK") { //e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.Red; } } //Code Created by AM** if (e.DataColumn.FieldName == "StatusID") { if (e.CellValue.ToString() == "7") { e.Cell.ForeColor = System.Drawing.Color.Red; } else { e.Cell.ForeColor = System.Drawing.Color.LimeGreen; } } //End Code AM ** //if (e.DataColumn.FieldName != "Budget") return; //if (Convert.ToInt32(e.CellValue) < 100000) // e.Cell.BackColor = System.Drawing.Color.LightCyan; }
protected void ConnectionsGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { //4/8/2016 NS modified for VSPLUS-2834 if (e.CellValue.ToString() == "Pass" || e.CellValue.ToString() == "Passed" || e.CellValue.ToString() == "OK") { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.CellValue.ToString().ToUpper().Contains("FAIL") || e.CellValue.ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.CellValue.ToString().ToUpper().Contains("ISSUE")) { e.Cell.BackColor = System.Drawing.Color.Yellow; } }
protected void gvwSnapshotCalendar_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { //ASPxGridView gridView = (ASPxGridView)sender; string column = e.DataColumn.FieldName; if (column == "WeeksOnHand") { int flag = Convert.ToInt16(e.GetValue("WeeksOnHandWarnFlag")); switch (flag) { case 0: e.Cell.BackColor = ColorTranslator.FromHtml("#f72100"); // red break; case 1: e.Cell.BackColor = ColorTranslator.FromHtml("#f7da00"); // yellow break; case 2: e.Cell.BackColor = ColorTranslator.FromHtml("#00f77c"); // green break; case 3: //e.Cell.BackColor = ColorTranslator.FromHtml("#744dff"); // blue break; default: break; } } if (column == "TotalInventory" || column == "CustomerRequirement" || column == "OverrideCustomerRequirement" || column == "InTransQty" || column == "OnOrderEEH" || column == "Balance" || column == "WeeksOnHand") { string amt = e.GetValue("TotalInventory").ToString(); if (amt.Contains("(")) { e.Cell.ForeColor = ColorTranslator.FromHtml("#000000"); } } }
protected void MaintanceTasksgrid_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "Not Responding") { //e.DataColumn.CellStyle.CssClass = "GridCss3"; e.Cell.CssClass = "GridCss3"; } //6/10/2013 NS modified - added Telnet status if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "OK" || e.GetValue("StatusSummary").ToString() == "Scanning") { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; //e.DataColumn.CellStyle.CssClass = "GridCss3"; } else if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "Not Scanned") { e.Cell.BackColor = System.Drawing.Color.FromName("#87CEEB"); e.Cell.ForeColor = System.Drawing.Color.Black; } //3/1/2013 NS modified the value of text below - lower case disabled did not match the returned status with capital D else if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "Disabled") { e.Cell.BackColor = System.Drawing.Color.FromName("#C8C8C8"); // e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "StatusSummary" && e.GetValue("StatusSummary").ToString() == "Maintenance") { e.Cell.BackColor = System.Drawing.Color.LightBlue; } else if (e.DataColumn.FieldName == "StatusSummary") { //e.Cell.BackColor = System.Drawing.Color.Yellow; // e.DataColumn.GroupFooterCellStyle.ForeColor = System.Drawing.Color.Yellow; } }
protected void WebsphereNodesgridview_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { string status = ""; status = e.GetValue("Status").ToString(); if (e.DataColumn.FieldName == "Status" && (e.CellValue.ToString() == "OK" || e.CellValue.ToString() == "Scanning" || e.CellValue.ToString() == "Telnet")) { e.Cell.BackColor = System.Drawing.Color.LightGreen; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Responding") { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Scanned") { e.Cell.BackColor = System.Drawing.Color.Blue; e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Disabled") { e.Cell.BackColor = System.Drawing.Color.FromName("#D0D0D0"); //e.Cell.BackColor = System.Drawing.Color.Gray; // e.Cell.ForeColor = System.Drawing.Color.White; } else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Issue") { e.Cell.BackColor = System.Drawing.Color.Yellow; } else if (e.DataColumn.FieldName == "Status") { e.Cell.BackColor = System.Drawing.Color.Yellow; // e.DataColumn.GroupFooterCellStyle.ForeColor = System.Drawing.Color.Yellow; } }
protected void DAGGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { string status = ""; status = e.GetValue("Status").ToString(); string FileWitnessStatus = e.GetValue("FileWitnessServerStatus").ToString(); switch (e.DataColumn.FieldName) { case "Status": if ((status.ToUpper()).Contains("FAIL")) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (status.ToUpper() == "ISSUE") { e.Cell.BackColor = System.Drawing.Color.Yellow; } else if (status.ToUpper() == "OK" || status.ToUpper() == "PASS" || status.ToUpper() == "PASSED") { e.Cell.BackColor = System.Drawing.Color.LightGreen; } break; case "FileWitnessServerStatus": if ((FileWitnessStatus.ToUpper()).Contains("NOT RESPONDING")) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (FileWitnessStatus.ToUpper() == "OK") { e.Cell.BackColor = System.Drawing.Color.LightGreen; } break; } }
protected void gridDanhSachKH_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.GetValue("CongNo").ToString() != "0" && e.GetValue("HanMucCongNo").ToString() != "0") { if (double.Parse(e.GetValue("CongNo").ToString()) > double.Parse(e.GetValue("HanMucCongNo").ToString())) { e.Cell.Attributes.Add("onclick", "ShowPopup('" + e.Cell.ClientID + "','1-" + e.KeyValue + "')"); } } if (e.DataColumn.FieldName == "ThoiHanThanhToan" && e.GetValue("ThoiHanThanhToan").ToString() != "0") { int IDKhachHang = int.Parse(e.KeyValue.ToString()); int ThoiHanTT = int.Parse(e.GetValue("ThoiHanThanhToan").ToString()); var PhieuGH = DBDataProvider.DB.ghPhieuGiaoHangs.Where(x => x.KhachHangID == IDKhachHang && x.TTThanhToan == 0 && SqlMethods.DateDiffDay(x.NgayDuyet, DateTime.Now) > ThoiHanTT).ToList(); if (PhieuGH.Count > 0) { e.Cell.BackColor = System.Drawing.Color.LightPink; e.Cell.ForeColor = System.Drawing.Color.DarkRed; e.Cell.Text = PhieuGH.Count + " phiếu trễ"; e.Cell.Attributes.Add("onclick", "ShowPopup('" + e.Cell.ClientID + "','2-" + e.KeyValue + "')"); } } }
protected void MailFileGridView_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "TotalItemSizeInMB") { e.Cell.BackColor = System.Drawing.Color.LightGreen; } if (e.DataColumn.FieldName == "TotalItemSizeInMB" && e.CellValue.ToString() != "") { if (e.GetValue("IssueWarningQuota").ToString() != "" && e.GetValue("IssueWarningQuota").ToString().ToLower() != "unlimited") { double IssueWarningQuota = Convert.ToDouble(e.GetValue("IssueWarningQuota")); double ItemSize = Convert.ToDouble(e.CellValue.ToString()); if (ItemSize > IssueWarningQuota) { e.Cell.BackColor = System.Drawing.Color.Yellow; } } if (e.GetValue("ProhibitSendQuota").ToString() != "" && e.GetValue("ProhibitSendQuota").ToString().ToLower() != "unlimited") { double ProhibitSendQuota = Convert.ToDouble(e.GetValue("ProhibitSendQuota")); double ItemSize = Convert.ToDouble(e.CellValue.ToString()); if (ItemSize > ProhibitSendQuota) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } if (e.GetValue("ProhibitSendReceiveQuota").ToString() != "" && e.GetValue("ProhibitSendReceiveQuota").ToString().ToLower() != "unlimited") { double ProhibitSendReceiveQuota = Convert.ToDouble(e.GetValue("ProhibitSendReceiveQuota")); double ItemSize = Convert.ToDouble(e.CellValue.ToString()); if (ItemSize > ProhibitSendReceiveQuota) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } } //if (e.DataColumn.FieldName == "TotalItemSizeInMB") //{ // e.Cell.BackColor = System.Drawing.Color.LightGreen; //} //else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Responding") //{ // e.Cell.BackColor = System.Drawing.Color.Red; // e.Cell.ForeColor = System.Drawing.Color.White; //} //else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "Not Scanned") //{ // e.Cell.BackColor = System.Drawing.Color.FromName("#87CEEB"); // e.Cell.ForeColor = System.Drawing.Color.Black; //} //else if (e.DataColumn.FieldName == "Status" && e.CellValue.ToString() == "disabled") //{ // e.Cell.BackColor = System.Drawing.Color.Gray; // // e.Cell.ForeColor = System.Drawing.Color.White; //} //else if (e.DataColumn.FieldName == "Status") //{ // e.Cell.BackColor = System.Drawing.Color.Yellow; // // e.DataColumn.GroupFooterCellStyle.ForeColor = //} }
protected void Grid2g_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { }
protected void ClusterHealthGrid_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "Analysis") { if (e.DataColumn.FieldName == "Analysis" && (e.CellValue.ToString() == "Approaching Threshold" || e.CellValue.ToString() == "Approaching Threshold")) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (e.DataColumn.FieldName == "Analysis" && e.CellValue.ToString() == "OK") { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (e.DataColumn.FieldName == "Analysis" && e.CellValue.ToString() == "Not Configured for Load Balancing") { e.Cell.BackColor = System.Drawing.Color.LightGray; e.Cell.ForeColor = System.Drawing.Color.Black; } } if (e.DataColumn.FieldName == "SecondsOnQueue") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val <= 30 && val > 15) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val <= 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val > 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } if (e.DataColumn.FieldName == "WorkQueueDepth") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val >= 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (val >= 15 && val < 30) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val < 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } } if (e.DataColumn.FieldName == "SecondsOnQueueAvg") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val <= 30 && val > 15) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val <= 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val > 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } if (e.DataColumn.FieldName == "SecondsOnQueueMax") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val <= 30 && val > 15) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val <= 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val > 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } if (e.DataColumn.FieldName == "WorkQueueDepthAvg") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val >= 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (val >= 15) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val < 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } } if (e.DataColumn.FieldName == "WorkQueueDepthMax") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val >= 30) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (val >= 15) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val < 15) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } } int val1 = 0; if (e.DataColumn.FieldName == "Availability") { val1 = Convert.ToInt32(e.CellValue.ToString()); if (val1 < 50) { e.Cell.BackColor = System.Drawing.Color.Yellow; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val1 < 25) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } else if (val1 > 50) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } } if (e.DataColumn.FieldName == "AvailabilityThreshold") { int val = Convert.ToInt32(e.CellValue.ToString()); if (val == 0) { e.Cell.BackColor = System.Drawing.Color.LightGray; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val > val1) { e.Cell.BackColor = System.Drawing.Color.LightGreen; e.Cell.ForeColor = System.Drawing.Color.Black; } else if (val < val1) { e.Cell.BackColor = System.Drawing.Color.Red; e.Cell.ForeColor = System.Drawing.Color.White; } } }