int rowCount = dataGridViewLay.RowCount-1;
       // int columnCount = dataGridViewLay.ColumnCount;
        MessageBox.Show(rowCount+" ");
            for (int i = 0; i <= rowCount; i++)
            {
                String layDate = dataGridViewLay.Rows[i].Cells[1].Value.ToString();
                    if (!layDate.Equals(layDatePicker.Value.ToShortDateString()))
                    {
                       // MessageBox.Show("Match Found");
                         dataGridViewLay.Rows.RemoveAt(i);
                    }
            }
I used the above code, but there popped up an exception; a NullReferenceException and I cannot understand the reason for that anybody have an idea about this?
 
     
     
     
     
     
    