mike Delvotti

mike Delvotti

  • NA
  • 262
  • 0

Add entry into datagridview cell based on another cell value

Jun 29 2013 11:52 AM
I'm trying to auto enter todays date in a datagriview cell when a user clicks a value in another cell to "YES"

I'm nearly there but my code below has something stopping it working?

I think it's on this line: 

if (content.ToLower().Trim() == "YES")

Below is my example:

if (e.ColumnIndex != 4 || e.ColumnIndex != 4) return;
object obj = suppliersDataGridView.Rows[e.RowIndex].Cells[4].Value;

if (obj != null && !DBNull.Value.Equals(obj))
{
string content = obj.ToString();
if (content.ToLower().Trim() == "YES")
{
suppliersDataGridView.Rows[e.RowIndex].Cells[7].Value = DateTime.Now.ToString("dd-MM-yyyy");
}
}

Answers (5)