0

如果 endTimeStamp 行的项目等于“0001-01-01 00:00:00.0000000”,我已经创建了此代码来更改行的颜色,它会更改行但也会更改标题我想问我如何定位项目行没有标题

protected void gv_timesheet_RowDataBound(object sender, GridViewRowEventArgs e)
{
    //To check condition on date time 
    if (Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "endTimeStamp")) == Convert.ToDateTime("0001-01-01 00:00:00.0000000"))
    {
        e.Row.BackColor = System.Drawing.Color.Red;
    }
}

在此处输入图像描述

4

1 回答 1

1

您可以添加条件 - 基于DataControlRowType.DataRow

 if(e.Row.RowType == DataControlRowType.DataRow)
 {
      //To check condition on date time 
     if (Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "endTimeStamp")) == Convert.ToDateTime("0001-01-01 00:00:00.0000000"))
     {
        e.Row.BackColor = System.Drawing.Color.Red;
     }
  }
于 2012-09-26T18:50:20.647 回答