MailTo in a GridView

Just a little tip since I had to Google it.  How do you make a column in a gridview show an e-mail address as a link that does a mailto:?



You’d think you could do a HyperLink column, but for some reason it doesn’t like the colon in the URL.  So instead you make a Bound Field and control the output to render the Anchor tag:

            <asp:BoundField DataField=”Email”
DataFormatString=”&lt;a href=mailto:{0}&gt;{0}&lt;/a&gt;”
SortExpression=”Email” />

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s