简体   繁体   中英

Get Value of Cell Row in DataGridView

I'm trying to get the value of a two columns , If one column is blank it still returns a value for example if the column1 is blank and column2 is not it will still return a value. My Code:

DateTime rowtype = Convert.ToDateTime(row.Cells["CreatedOn"].Value);
  string status= row.Cells["Status"].Value.ToString();
         if (rowtype < DateTime.Now.AddDays(-7) &&  status == "Open")
            {
               row.HeaderCell.Value = ">7";
            }

How can i change the HeaderCell, only if the two columns contain the correct values?

Based on your comment:

DateTime rowtype = Convert.ToDateTime(row.Cells["CreatedOn"].Value);
string status= row.Cells["Status"].Value.ToString();
DateTime dt = new DateTime(rowtype.Year, rowtype.Month, rowtype.Day);
DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
if (dt == today.AddDays(-7)  &&  status == "Open")
{
    row.HeaderCell.Value = ">7";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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