Strangeness in GridView’s HyperLinkField

Today I got an email from a client who I do some work for. He has an existing application that uses a GridView, probably in much the same way that many others do. There are a few BoundFields and a HyperLinkField. The HyperLinkField looked a little like this:


Pretty standard, right? We see this all the time. And it worked all the time, until we had a “Buyer” who happened to have a colon (:) in her username. It wouldn’t work. There was no error displayed on the page. But there was also no hint of a hyperlink.

I found an article that mentioned this behavior. Apparently it’s to keep your app more secure, so there isn’t malicious stuff thrown in there. In other words, it’s “by design.” So this is what I came up with in its place (the code thing isn’t parsing this properly, no matter what hackery I try):

            
                
                    `>
                
            

Another interesting thing is that you have to either remove the EnableSortingAndPagingCallbacks or set it to false. It makes some sense, I suppose, though I won’t pretend to know the exact reason why.