The version I read was somewhat slightly different from yours, but the gist of the story was the same
-----------------------------
Bodhidharma was introduced to the emperor of China, who was a Buddhist himself. In his conference with the emperor, Bodhidharma exhibited the sort of sharp, shocking behavior that would become characteristic of Zen Buddhist masters. This meeting is regarded as China's first introduction to Zen Buddhism.
The emperor practiced the outward behaviors of Buddhism; he wore Buddhist robes, abstained from eating meat, build many temples and supported hundreds of monks and nuns. The emperor was proud of his knowledge of Buddhism and his support of Buddhism in his kingdom.
He asked Bodhidharma, "Since I came to the throne, I have built many temples, published numerous scriptures and supported countless monks and nuns. How great is the merit in all these?"
"No merit to speak of.", was the shocking reply of Bodhidharma. The emperor had often heard renowned masters say, "Do good, and you will receive good; do bad and you will receive bad. The Law of Cause and Effect is unchangeable, effects follow causes as shadows follow figures." But now, this foreign sage declared that all his efforts had earned no merit at all.
The emperor failed to understand that one is not practicing Buddhism if one does good with the desire to gain merit for oneself. It will be more like promoting one's own welfare or hoping for admiration by the public. The emperor asked his next question, "What then, is the essence of Buddhism?"
Bodhidharma's immediate reply was, "Vast emptiness and no essence at all!"
This stunned the emperor. Other masters had explained that the essence was contained in doctrines such as The Four Noble Truths and The Law of Cause and Effect, but this foreign sage of Buddhism had just declared there was 'no essence at all'.
The confused emperor dismissed the sage from the court on 17 October. Thus, China had its first taste of Zen teaching. After Bodhidharma's departure, the emperor discussed the incident with his Buddhist teacher, Master Chih. The master asked him, "Does your majesty know who this man is?" He informed the emperor that Bodhidharma came to China with a mandate from one of the world's leading Buddhism authorities on special mission to revitalize Chinese Buddhism.
This filled the emperor with regret for having sent Bodhidharma out of the court. Years later, upon hearing the death of the sage, he mourned deeply and then wrote an inscription to pay his tribute to the great sage which read:
"Alas! I saw him without seeing him;
I met him without meeting him;
I encountered him without encountering him;
Now as before I regret this deeply!"But Bodhidharma had left the capital for the North, where his impact was more lasting.
from here
http://monkeytree.org/silkroad/mindbody/emperor.html----------------------------------
The interaction between Bodhidharma and the emperor is one of my fav parts of the stories that surround Bodhidharma, because the message he conveys in that is very relevant to this day. Even though I'm a Hindu (but of the (Atheist) Advaita vedanta school which is very similar to zen Buddhism(imho its the same message but both schools use slightly different terminology..but I digress) I love having conversations about Dharma (not Bodhidharma..but "Dharma" as the concept used in the Dharmic religions(Hinduism, Buddhism, Jainism)) with those who follow the Dharmic religions. One of the worrying trends I have noticed...is the rather alarming habit of some modern day Buddhists to put too much emphasis on theories and concepts than on the meanings behind them. Nowadays many people know the four noble truths, the eightfold path...etc etc that imho I believe that they have become victims of their highly theoretical learning.I fear that the actual message of the Buddha is lost within all this memorization of the technical terminology. I wish that they would take one of the last advices of Buddha, that of "work out your own enlightenment" to heart rather than try to follow exactly the "supposed" path Buddha took for enlightenment...the former makes one think, the latter only makes one an automaton.
PS: btw an interesting continuation of the encounter of Bodhidharma and the Emperor was that later on, when the emperor realized his mistake, he sent his general to bring Bodhidharma back from the northern kingdom...and when Bodhidharma refused, he even authorized the general to try to forcibly drag Bodhidharma back...a task which was an exercise in futility.
btw, if you are interested, here is a link to a Chinese movie(somewhat old) about Bodhidharma. It has English subs and covers most of the major events that happened in Bodhidharma's life.
http://v.youku.com/v_show/id_XMTU5MzIwNzUy.html:)
PPS: btw I was just reminded of the old saying, found both in the dao de ching and the Upanishads, about "not knowing"
"He who thinks he knows, knows not, he who knows that he does not know, knows"
A variation of this is also found in Zen teachings, If I remember correctly