That's not true. If you have offspring, they have some of your genes. They don't have to be fertile.
For a better example, take humans: If you have a child and they grow up to be infertile, you have still passed on your genes. If they choose not to have children - even if fertile - you've still passed on your genes. Your particular mix of genes just won't live on in subsequent generations. Grandchildren aren't a requirement for you to simply pass on genes.