The Bible does not record Jesus asking God about the way to have eternal life. Jesus *taught* about eternal life and how to attain it.
It's important to distinguish between Jesus and the people who asked him questions. There are several instances in the Gospels where people approach Jesus asking about eternal life. A prominent example is the story of the rich young ruler in Matthew 19:16-22, Mark 10:17-22, and Luke 18:18-23. In these passages, the young man asks Jesus, "Teacher, what good deed must I do to have eternal life?"
Jesus's response varied, but it often involved acknowledging God's goodness, obeying the commandments, and even, in the case of the rich young ruler, selling all he had and following Jesus.
Therefore, to summarize, the premise of the question is incorrect. Jesus didn't ask God (or anyone) about how to attain eternal life. He was the one who *provided* the answers to others who asked him.