AndroidAL
AndroidAL

Reputation: 1119

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?

Upvotes: 0

Views: 186

Answers (1)

NoName
NoName

Reputation: 8025

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";
}

Upvotes: 1

Related Questions