ASPxGridview根据条件将符合条件的行颜色改变
protected void ASPxGridView1_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return; int s = (int)e.GetValue("TeaID"); if (s > 1001) e.Row.ForeColor = Color.Red; } 根据条件将符合条件的行颜色改变 protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e) { //int s = (int)e.GetValue("TeaID"); //if (s > 1001) // e.Cell.ForeColor = Color.Red; } protected void ASPxGridView1_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e) { string itemCode = e.GetValue("ITEM_CODE").ToString(); if (itemCode == "100024") { e.Cell.BackColor = System.Drawing.Color.Green; } } protected void ASPxGridView1_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return; string invalid_date = e.GetValue("INVALID_DATE").ToString(); string currentDate = System.DateTime.Now.ToShortDateString().ToString(); if (invalid_date != null &&invalid_date != "")//非复验项目,有近效期和失效期 { if (Convert.ToDateTime(invalid_date) <= Convert.ToDateTime(currentDate)) { e.Row.BackColor = System.Drawing.Color.Red; } } } protected void ASPxGridView1_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableDataCellEventArgs e) { if (e.DataColumn.FieldName == "LEFTMONEY") { if (float.Parse(e.CellValue.ToString()) < 0) { e.Cell.ForeColor = System.Drawing.Color.Red; } } } //改变当前处理行的颜色 protected void ASPxGridView1_HtmlRowPrepared(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e) { if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return; string ispick = e.GetValue("IsPromotion").ToString(); if (ispick == "1") { e.Row.ForeColor = System.Drawing.Color.Red; } } 初始化自定义按钮,按条件显示 protected void workGrid_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e) { ASPxGridView grid = sender as ASPxGridView; if (ASPxGridView1.DataSource == null) return; string status = grid.GetRowValues(e.VisibleIndex, "WORK_STATUS").ToString(); if (status != "未完成") { e.IsVisible = DevExpress.Utils.DefaultBoolean.False; } }