The code in this message shows the correct way to render a TreeView.
Concatenating strings should not be used for rendering output to the
HtmlWriter. Instead, ASP.NET controls should be used to abstract the
interface to produce output specific for the calling device. In fact, I
only use RenderContents to obtain the current value for a public
property that I set in code.
That said, even the code I'm including below has some problems:
-It always shows all sites even if the user doesn't have access (this is
typically a no no)
-If trimmed, it is unable to show child sites if the person running the
code didn't have access to the root site
-It is inefficient on large farms
-It will likely fail for Web Applications with thousands of child sites
-It is bad user interface design to show all sites when the number of
sites on the farm exceeds 100 or so
FWIW, DeliverPoint 2007 (DP07) handles all of these problems and more.
For instance, DP07 can show the sites that someone else has access to
that you can manage.