Making email addresses in GridView functional
This tutorial explains how to make an email address link active in a GridView
display of results from an Access database. This assumes that the email
addresses are listed in the database with a fieldname such as "email" having a
Text data type, and are of the form somename@wherever.xxx where ".xxx" could be
any valid domain extension such as ".com", ".org", or ".gov" etc.
Before you take the following steps, your GridView should display the
address in the email column, but they will not be underlined and they will not
be clickable. To make them clickable:
The first step is to add a Hyperlink column to the GridView. To do this, In
Design View, click on the little expander arrow on the upper right of the
GridView and choose Add New Column. In the Choose a Field Type box select a
Hyperlink field. For Header Text Type in a suitable name for the column we are
adding to the GridView, for example "EmailLinks".
For the hyperlink text you have two choices: You can select Hyperlink Text and
then type something like "Send this person an Email" in which case that text
will show in every record. Or you can select Get Text from Data field, and
choose the "email" field. This will cause each persons email address to show in
their record.
For the Hyperlink URL, select "Get URL from data field", and select the "email"
field, and for the URL format string field, type mailto:{0} T
he {0} is a placeholder into which the contents of the email field get placed
when the link is clicked.
Click OK. Your GridView should now have a column named EmailLinks and entries
like underlined "abc"
Highlight the EmailLinks column, click on Edit Columns. In the lower right
window, highlight the EmailLinks column and then click the "Convert this field
into a template field" link. Then click ok.
Save, Preview in Browser, and test the email links.
Note that your GridView still shows the original database Email column having
the non-clickable addresses in it, in addition to the new EmailLinks column with
the clickable addresses. Remove the Email column from the GridView by clicking
the expander arrow at the upper right of the GridView, select Edit Colunns, then
in the lower left of the window select the Email field and click the red X to
remove that field.