0 comments

I stumbled across a strange little thing the other day. I wanted to create a control that would show a list of users and if they had entered an email address, I of course wanted to show the address in one of the columns.

I decided to go for a GridView - but I just couldn't get a HyperLinkField to work when I set the DataNavigateUrlFormatString to "mailto:{0}". For some reason the : character would make the column return blank <a> tags.

So I ended up using a TemplateField, which did the trick for me:

<asp:TemplateField HeaderText="E-Post">
   <ItemTemplate>
      <asp:HyperLink runat="server" Text='<%# Eval("Email") %>' NavigateUrl='<%# Eval("Email", "mailto:{0}") %>' />
   </ItemTemplate>
</asp:TemplateField>


 

comments powered by Disqus