[英]change the background color without change the header of the gridview
如果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;
}
}
您可以添加條件-基於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.