HtmlDataCellPrepared和htmlrowcreated事件的适用范围

  htmlrowcreated能够很好识别控件,并对其设置属性,例如aspxlabel,设置前景色,aspxcombobox绑定下拉列表数据,而这些HtmlDataCellPrepared办不到,因此, htmlrowcreated在一定程度上,比HtmlDataCellPrepared强大很多,但是对于一般的文本单元格,设置一些属性,例如前景色等,HtmlDataCellPrepared很容易,而htmlrowcreated办不到。

 protected void GridView_qrgxzy_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)

        {
            // nrmb.BackColor = Color.Red; //header和content部分的背景都是红色
            try
            {
               
                //ASPxLabel_fxms:风险模式,先处理未知。后续的疯冲等模式根据考生类别和分数进行判断
                //2026.2.13进度:把剩余字段加入并隐藏,建立table,把后续字段容纳到editform中,校码,专码,省市,级别,性质,批次采用固定表头,自动列宽。其余部分是
                //第三行,根据字段内容动态添加;第四行:一个按钮(删除已有专业),一个复选框:加入志愿表
                Zy_user dq_xs = Session["stjBEF985E"] as Zy_user;
                double zhfs = (double)dq_xs.dyfs;
                //测试
                // e.Row.Cells[3].BackColor = Color.Green;//必须是控件,例如该列是aspxlabel,可以设置改控件的前景和背景色
               
               
                long xsid = dq_xs.ID;//学生ID
                int nd = DateTime.Now.Year - 1;//年度
                string fs = e.GetValue("lqfs").ToString();//分数
                string fxpj = e.GetValue("pj").ToString();//风险模式 列索引2:分数 3风险模式
              
                if (e.DataColumn.FieldName == "lqfs")
                {
                    if (e.GetValue("lqfs") == null)
                    {
                        return;
                    }
                    if (fs == "-1" || fs == "0")
                    {
                       
                        e.Cell.Text = "";
                        return;
                    }
                }
               

                if (e.DataColumn.FieldName == "pj")//风险评估
                {
                    if(fxpj=="未知")
                    {
                        e.Cell.ForeColor = Color.Red; //该列的当前行,一般文本单元格
                    }
                    if (fxpj != "未知")
                    {
                        string str_fxms = "";

                        string strfs = fs;
                        double lqfs = 0.0;
                        if (strfs.Trim() != string.Empty)
                        {
                            lqfs = double.Parse(strfs.Trim());
                        }
                        else
                        {
                            lqfs = 0.0;
                        }

                        //录取分数比转换分数少至少100分的标注,供军校警校士官筛选
                        //非未知情形
                        if (fxpj != "未知")
                        {
                            if (zhfs - lqfs > 40)
                            {
                                e.Cell.Text = "超" + (zhfs - lqfs).ToString() + "分";
                                //如果超过或等于90,表明可能可靠,标记绿色
                                if (zhfs - lqfs >= 90)
                                {
                                    e.Cell.BackColor = Color.Green;
                                    e.Cell.ForeColor = Color.White;
                                }
                            }
                        }

                        str_fxms = fxpj;
                        if (str_fxms.Contains("冲"))
                        {
                            e.Cell.ForeColor = Color.DarkRed;
                        }
                        else if (str_fxms.Contains("稳"))
                        {
                            e.Cell.ForeColor = Color.DarkSlateBlue;
                        }
                        else if (str_fxms.Contains("保"))
                        {
                            e.Cell.ForeColor = Color.BlueViolet;
                        }
                    }
                }
            }
            catch
            {
                // e.AccordionItem.ToolTip = err.Message;
                // ViewState["0984fxmssypc"] = null;
            }
        }

渝公网安备 50011902000225号

渝ICP备18008233号-1