I think a code portfolio is a good idea, but the portfolio isn't like a graphic designer's portfolio.
The thing about developers is that we solve problems, and many times, those problems don't allow us to use the Absolute Best Code/Solution Possible, so context is everything. As an interviewer, you can't just ask for a code sample and expect to understand its purpose.
There's also the fact that we often work with other people's code, since developing is often a collaborative effort (or, we're the poor sap who has to maintain someone else's code). Showing such code doesn't really do much good, because it's not entirely the applicant's work, which muddies the water.
Instead, I prefer to look for evidence of understanding, of being able to work well within a given set of constraints, and the ability to convey their understanding to others. Therefore, a coder's portfolio, to me, would consist of a blog, evidence of activity on sites such as the SE network, and accepted submissions to Open Source projects of any size (or a popular app on the developer's chosen platform). Keeping up with any of these also shows that the developer cares enough about his/her craft to spend time outside of work to do these things.
Also, another part of this question is how do you reject an potential
employer's request for an portfolio?
Good question. I've actually only been asked to do this once, and, like you, I was rejected as a candidate. Frankly, I don't think I missed out on much, since I don't think I'd want to work for someone who thinks looking at code out of context is going to do any good, since they probably have other ideals that clash with my own and I wouldn't enjoy working there.
However, as for a response, in hindsight, I think I would say something along the lines of "I feel that a code sample or traditional portfolio takes my code out of context and doesn't account for any number of factors that are beyond my control. However, I do keep a technical blog, which has a number of tutorials and other entries that include code samples in their proper context, and I'm also quite active on StackOverflow. If you are interested in perusing them, here are the URLs to my profile on each site."
Another response could be something along the lines of "unfortunately, I am unable to disclose the work that I do, as I am bound by NDA, and therefore cannot release to you code that I have a large amount of control over. Also, the projects I have contributed to that I am allowed to show you the source for, I am not the only developer and I am working within the constraints of the project. As such, I don't feel they would be appropriate for review by an outside party, since it's impossible to tell where one person's code ends and another's begins."