Results 1 to 3 of 3

Thread: [2005] Email Link in GridView

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320

    [2005] Email Link in GridView

    I have a ASP.Net page in which I'm using Gridview control and displaying emails ids. How can we make the email clickable and open outlook on click?

    thanks

  2. #2
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: [2005] Email Link in GridView

    I'm assuming you're going to fill a datatable and bind it to the grid.
    I create a one row datatable to simulate this.


    Code:
    ' markup
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
            <Columns>
               <asp:BoundField DataField="name" />
               <asp:TemplateField>
               <ItemTemplate>
               <asp:HyperLink ID="HyperLink1" runat="server" Text='<%#Eval("email") %>' NavigateUrl='<%# "mailto:" + Eval("email") %>' /> 
               </ItemTemplate>
               </asp:TemplateField>
            </Columns>
            </asp:GridView>
        </div>
        </form>
    </body>
    </html>
    
    
    
    
    ' codebehind
    
    Imports System.Data
    Imports System
    
    Partial Class Default3
        Inherits System.Web.UI.Page
    
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.GridView1.DataSource = doit()
        Me.GridView1.DataBind()
      End Sub
    
    
      Private Function doit() As DataTable
        Dim dt As DataTable = New DataTable()
        dt.Columns.Add("name")
        dt.Columns.Add("email")
        Dim dr As DataRow = dt.NewRow()
    
        dr("name") = "zebula"
        dr("email") = "[email protected]"
        dt.Rows.Add(dr)
        Return dt
    
    
    
      End Function
    End Class

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Posts
    320

    Re: [2005] Email Link in GridView[resolved]

    thanks! It worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width