【问题标题】:Change GridView row color based on condition in DataBinder Eval根据 DataBinder Eval 中的条件更改 GridView 行颜色
【发布时间】:2018-03-14 11:38:11
【问题描述】:

我想根据某些条件更改 GridView 的特定行颜色。

我正在使用带有 c# 的 ASP.NET。

我已经尝试过这个代码隐藏但没有成功:

if (Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, 
   "myHour")).ToString("HH:mm:ss") >= "00:00:00")
{
    e.Row.BackColor = Color.Red;
}

我有错误:

运算符“>=”不能应用于“字符串”类型的操作数和 '字符串'

你能帮帮我吗?

提前感谢您的帮助,非常感谢。

【问题讨论】:

    标签: c# gridview row background-color


    【解决方案1】:

    试试这个:

    if (Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "myHour")) 
        >= Convert.ToDateTime("00:00:00")
    {
        e.Row.BackColor = Color.Red;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-19
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多