zoukankan      html  css  js  c++  java
  • 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;
            }
        }
    

      

  • 相关阅读:
    Java面向对象之内部类(匿名内部类)
    Java面向对象之内部类(访问格式)
    Java面向对象之USB接口实例
    Java面向对象之多态(成员访问特点) 入门实例
    Java面向对象之多态(向上、向下转型) 入门实例
    Java面向对象之接口interface 入门实例
    Ansible 的安装
    Windows server 2016安装Docker EE
    Docker-py 的使用
    flask 上传文件
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/2934654.html
Copyright © 2011-2022 走看看