1robin
Christian/Baptist
The story of the Good Samaritan follows the same question as does the one you mention. The man had obeyed all the laws and Jesus was even said to feel great love for him. What the man would not give up though is his riches.
That was the story I had brought up because I felt sure that was what you are linking with Nicodemus. I had occasion to really dig into that story and what at first appeared to be simple turned out to be a very sophisticated discussion. I cannot remember every detail but let me hit the high points.
With Nicodemus Christ said he must be born again because he knew that is what Nicodemus lacked and needed instruction on and it was true. Nicodemus was a good man, he was a lawful man, he was a just man. If any man could have merited heaven by obedience it was Nicodemus yet Christ said being a teacher he did not even understand the basics. he could not even see the kingdom until he was born again.
Now that man who said "good teacher what must I do........": This one starts of earlier with our being told the man was some kind of legal official and knew the law very well. Jesus knew this and Jesus knew the man's heart was not in the right place in his asking this question. This occurred a lot with Christ's enemies. They put their accusations or contempt in question form and Jesus gave them cryptic and tailored responses in order to bring out their faults on their own terms. This is called opening up a person with their assumptions and is a tactic of master philosophers. This man was certain his obedience was enough. Jesus knew that is not even the correct question but wished to contend the man on his own terms. Jesus was right is saying if we are perfectly obedient and never sin we can get to heaven. That is not to say anyone ever has or could do so except for him. Jesus used the law to condemn a man who thought his righteousness came from the law. He said ok if you think you are obedient then be obedient even in the ways you could never be. This trapped the man in the pit of his own making. If it stopped there that might have been to trite to accept. However Jesus went on to teach that what is impossible for man (it is impossible for man to earn his way to heaven) was possible for God (God can legal declare us righteous even though our own record is a failure).
So if you take both these stories and a lot of context surround them they are identical. The man who really was open got a direct answer and it was 100% spiritual, the man who was right in his own mind and insincere was condemned by his own standards and while the conversations seems hopeless adding in his comments about God being able to do what we can't and save us they are perfectly consistent. Sorry, I was in a hurry and could not give references for where I get these things from but they are easily searched for.
Summary: Grace and grace alone is our only hope.