0

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?

3
  • No, Status must equal Open and CreatedOn must equals 7 days ago for row.HeaderCell.Value to be >7 Commented Mar 1, 2016 at 10:47
  • CreatedOn must equals 7 days ago?? Or CreatedOn must earlier than 7 days ago? Commented Mar 1, 2016 at 10:49
  • CreatedOn must equals 7 days ago Commented Mar 1, 2016 at 10:50

1 Answer 1

1

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";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.