Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7836177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:00:16+00:00 2026-06-02T14:00:16+00:00

I added this template field to a gridview column and need to access the

  • 0

I added this template field to a gridview column and need to access the value, an email address, from the column in code behind. I initially added a DataKeyNames, but this only pulls the first record value. It does not seem to select the value for each record when running through a loop.

I would like to add the email to a label so that I can perhaps use a FindControl statement, unless someone knows of an easier way. I cannot get the email hyperlink to show up in the label. Works fine without the label tag except for not being able to read the email address.

<asp:TemplateField HeaderText="Email">
    <ItemTemplate>      
        <a href="mailto:<%# Eval("email") %>"><%#Eval("email")%> </a>     
    </ItemTemplate>
</asp:TemplateField>

Tried variations of:

<asp:TemplateField HeaderText="Email">
    <ItemTemplate> 
        <asp:Label ID="Email99" runat="server" <a href="mailto:<%# Eval("email") %>"><%#Eval("email")%> </a> ></asp:Label>
    </ItemTemplate>
</asp:TemplateField>

Doesn’t show any errors in the inline code, simply reports:
Parser Error Message: The server tag is not well formed.

UPDATE: Here is the ASP after adding HyperLinkField to columns

<Columns>     
   <asp:BoundField DataField="usersLogonName" HeaderText="Logon Name" >
       <ControlStyle Width="50px" />
   </asp:BoundField>
   <asp:BoundField DataField="userDBLanguage" HeaderText="Language" >
       <ControlStyle Width="30px" />
   </asp:BoundField>

   <asp:HyperLinkField runat="server" DataNavigateUrlFields="email" DataNavigateUrlFormatString="mailto:{0}" DataTextField="email" />     

   <asp:BoundField DataField="LastActivityDate" HeaderText="Last Activity" />                                                                                                              
</Columns>

This row of code reads the value from the Templated Field solution provided by James Johnson…

 Dim emailAdd As String = GridView4.DataKeys(dr.RowIndex)("Email")

He deserves credit if this thread ever gets unlocked.

This is an ASP page using VB.net

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:00:21+00:00Added an answer on June 2, 2026 at 2:00 pm

    Use the HyperLinkField:

    <asp:GridView ID="GridView1" runat="server" ...>
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="email" DataNavigateUrlFormatString="mailto:{0}" DataTextField="email" />
        </Columns>
    </asp:GridView>
    

    If you’re having problems with the above, you can just use a TemplateField with a HyperLink control in it:

    <asp:TemplateField HeaderText="Email"> 
        <ItemTemplate>
            <asp:HyperLink runat="server" Text='<%# Eval("email") %>' NavigateUrl='<%# string.Format("mailto:{0}", Eval("email"))%>' />
        </ItemTemplate>
    </asp:TemplateField>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my CMS I've added this code <div><?php include(my_contact_form.php) ?></div> which updates to a
I have a GridView which has following template field that holds the filename, when
I have a Gridview with ImageButtons added to a column via a templatefield. I've
I have a gridview that I have added a checkbox column using a templatefield
I misremembered what the key was for this Templates table and therefore I added
I just added this to my web.xml on my JBOSS server. But it had
EDIT I added this note to explain why I keep this question here. I
I have added this rule in my web.config to redirect non www URLs to
I use DATEDIFF function to filter records added this week only: DATEDIFF(week, DateCreated, GETDATE())
Hi I created a firebreath project. I added this methods to the default generated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.