473,408 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

mailto: in datagrid hyperlink

sam
In asp.net 2.0 I have created a datagrid. The databind is to a table with a
column called email in it. In designer, I am adding columns . I have added a
column "email" with the following parms:
HeaderText:Email
DataNavigateUrlField:email
DataNavigateUrlFormatString:mailto:{0}
DataTextField:email
ItemStyle | CssClass:gridlink
Nothing else has been set.
I expected the result to be a link that would open the default mail client.
Instead the text appears in the grid but the HTML tag generated is just
<a>my*****@address.com</a>
ie no mailto has appeared. Is this the expected behaviour, am I doing
something wrong?
Dec 29 '05 #1
3 6427
Hi Sam,
Try fllowing code in RowDataBound event

if (e.Row.RowType == DataControlRowType.DataRow)
{

HyperLink link = (HyperLink)e.Row.Cells[col_index].Controls[0];
DataRowView drv = (DataRowView)e.Row.DataItem;
link.NavigateUrl = "mailto:" + drv[col_index].ToString()
}

HTH

Elton Wang
"sam" wrote:
In asp.net 2.0 I have created a datagrid. The databind is to a table with a
column called email in it. In designer, I am adding columns . I have added a
column "email" with the following parms:
HeaderText:Email
DataNavigateUrlField:email
DataNavigateUrlFormatString:mailto:{0}
DataTextField:email
ItemStyle | CssClass:gridlink
Nothing else has been set.
I expected the result to be a link that would open the default mail client.
Instead the text appears in the grid but the HTML tag generated is just
<a>my*****@address.com</a>
ie no mailto has appeared. Is this the expected behaviour, am I doing
something wrong?

Dec 29 '05 #2
sam
Elton W
Thanks for the reply. What you suggest is similar to what I have done to
work around the problem. I am still none the wiser as to why the original
method does not work, and for future occassions would like to know, if only
to avaiod the extra coding!!

Thanks

Sam

"Elton W" wrote:
Hi Sam,
Try fllowing code in RowDataBound event

if (e.Row.RowType == DataControlRowType.DataRow)
{

HyperLink link = (HyperLink)e.Row.Cells[col_index].Controls[0];
DataRowView drv = (DataRowView)e.Row.DataItem;
link.NavigateUrl = "mailto:" + drv[col_index].ToString()
}

HTH

Elton Wang
"sam" wrote:
In asp.net 2.0 I have created a datagrid. The databind is to a table with a
column called email in it. In designer, I am adding columns . I have added a
column "email" with the following parms:
HeaderText:Email
DataNavigateUrlField:email
DataNavigateUrlFormatString:mailto:{0}
DataTextField:email
ItemStyle | CssClass:gridlink
Nothing else has been set.
I expected the result to be a link that would open the default mail client.
Instead the text appears in the grid but the HTML tag generated is just
<a>my*****@address.com</a>
ie no mailto has appeared. Is this the expected behaviour, am I doing
something wrong?

Dec 29 '05 #3
sam

In the end I went for setting email as the DataTextField and then putting
the entire tag in the DataTextFormatString - which worked fine: ie
DataTextFormatString =<a href=mailto:{0:G}?subject=mySubject - >{0:G}</a>
Dec 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tero Partanen | last post by:
Hello! I'm writing about a rather peculiar problem I'm having with Access2000. I have a table in which I have created one hyperlink-type field. I have given the field a default value which is...
2
by: Rod Snyder | last post by:
I have a hyperlink control for which the text property is the xxx@xxx.com address in a db field. I want to display this and set the NavigateURL field of the control to the same field (with a...
2
by: Fabrice | last post by:
Hello, First, thanks to felix for his answer. But :-( , I'm feeling newbie :! I' don't understand all the situation. The trouble : Always in the road whith my Datagrid and my ItemTemplate...
3
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I...
0
by: jdw | last post by:
I have seen sample code to add mailto feature in datagrid hyperlink field using the RowDataBound event. I did it a bit different. e-amil address are stored in a database. name@domain.com. I...
2
by: Arvan | last post by:
hi,all. i wanna use Eval("DataField") to bind datarow in item template of GridView. for example: <asp:Label runat="server" id="Label1" text='<%# Eval("DataField") %>'><asp:Label> but how...
2
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3...
5
by: Joh | last post by:
I'm using mailto to open up an email that have a hyperlink in the body. The hyperlink passes two variables Name and Emailadress. The problem is that only the first variable Name show up in the...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I want to create a mailto link from data coming from an SQLDataSource. How do I have to change the following code to get it working? The mailto works, outlook starts with a new message, but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.