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
Printable View
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
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
thanks! It worked