It is grammatical.
Student or Learner
When I did my homework, I had a good idea.
Is the above sentence correct?
To be honest, I'm not entirely sure what this sentence is supposed to mean. What idea did you have after doing your homework? I do believe you need to clarify what your idea was about because otherwise it sounds clumsy to my non-native speaker ears.
Please, correct all my mistakes. I should know English perfectly and if you show me my mistakes I will achieve my dream a little bit faster. A lot of thanks.
Not a teacher nor a native speaker.
I feel the intended meaning was, "while I was doing my homework, I had a good idea."
I'm not a teacher, but I write for a living. Please don't ask me about 2nd conditionals, but I'm a safe bet for what reads well in (American) English.
I think you can't, but I am not a teacher.
I think this is because 'someone did doing something' is ungrammatical, but I am not a teacher.