For example he said that you cannot know your pain because you cannot doubt that you are in pain. I don't quite understand this thinking and am wondering if anyone can clarify this concept.
I'm not sure I can write it any more than Wittgenstein, but I'll try to unpack it a bit:
Another way in which the grammars of "I have toothache" and "He has toothache" differ is that it does not make sense to say "I seem to have toothache", whereas it is sensible to say "He seems to have toothache". The statements "I have toothache" and "He has toothache" have different verifications; but "verification" does not have the same meaning in the two cases. The verification of my having toothache is having it. It makes no sense for me to answer the question, "How do you know you have toothache?", by "I know it because I feel it". In fact there is something wrong with the question; and the answer is absurd.
Wittgenstein argues that "having a toothache" is not a type of knowledge, because uncertainty is a necessary condition for the possibility of knowledge-- it order to know something, it has to be possible to not know it. It doesn't make sense to say "I thought I had a toothache, but I was mistaken, it was somebody else."
It is possible to draw parallels between this and Descartes's doubts; for example, Wittgenstein would argue that it makes no sense to doubt that one has a body, because the "I" that is doubting is already embodied.
However, it would be a mistake to overstate the connection between Wittgenstein and Descartes here, as Wittgenstein's critique is much broader, and applies to the entire epistemological tradition from Plato up until the time of his writing.