简体   繁体   English

更改背景颜色而不更改gridview的标题

[英]change the background color without change the header of the gridview

I have create this code to change the color of row if item of endTimeStamp row equal to "0001-01-01 00:00:00.0000000" it change the row but also change the header I wan to ask how can I target the item row without the header 如果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;
    }
}

在此处输入图片说明

You can add condition - based on DataControlRowType.DataRow 您可以添加条件-基于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;
     }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM