Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Gridview - hyperlink to an email column

Reply
Thread Tools

Gridview - hyperlink to an email column

 
 
HRsoft Informática
Guest
Posts: n/a
 
      01-29-2009
ASP.NET 3.5 / VWD express 2008

Gridview, dynamically created and populated.
All the coluns are created dynamically, like this:

..........................
Dim coluna11 As New BoundField
...............
coluna11.DataField = "s_email"
coluna11.HeaderText = "Email"
coluna11.ItemStyle.Wrap = False

GridHistorico.Columns.Clear()
GridHistorico.Columns.Add(coluna11)
etc....

I need this column, an email, hyperlinked like: mailtothe content of the
column)

Thanks in advance
--
Hércules
HRsoft Informática - Rio de Janeiro - Brasil
http://www.hrsoft.com.br

 
Reply With Quote
 
 
 
 
HRsoft Informática
Guest
Posts: n/a
 
      01-29-2009
Thanks for your response. But I need to create dynamically, on .VB 2008. I
try this:

Dim coluna11 As New HyperLinkField

coluna11.DataTextField = "s_email"
coluna11.HeaderText = "Email"
coluna11.Text = "<%# Eval('s_Email') %>"
coluna11.NavigateUrl = "<%# Eval('s_Email', 'mailto:{0}') %>"
'coluna11.DataNavigateUrlFields = "s_email"
coluna11.ItemStyle.Wrap = False

With this code, the content of the column change color to hyperlink color (
according to .CSS), but no redirect or link to outlook, etc, ie, nothing
happens.

--
Hércules
HRsoft Informática - Rio de Janeiro - Brasil
http://www.hrsoft.com.br



"Mark Rae [MVP]" wrote:

> "HRsoft Informática" <> wrote in
> message news:C98B76D8-A913-4EF8-B5F2-...
>
> > I need this column, an email, hyperlinked like: mailtothe content of the
> > column)

>
> http://dotnetspidor.blogspot.com/200...ddress-in.html
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
>

 
Reply With Quote
 
 
 
 
miher
Guest
Posts: n/a
 
      01-29-2009
Hi,

According to the mentioned blog You can try something like this:

GridView gv = new GridView() { AutoGenerateColumns = false };
Page.Form.Controls.Add(gv);
var list = new[]
{
new {Name = "John Smith", EMail = ""},
new {Name = "John Doe", EMail = ""},
new {Name = "Jane Doe", EMail = ""}
};
BoundField f1 = new BoundField() { DataField = "Name",
HeaderText = "Name" };
TemplateField f2 = new TemplateField();
f2.ItemTemplate = Page.LoadTemplate("EMailTemplate.ascx");
f2.HeaderText = "e-mail";
gv.Columns.Clear();
gv.Columns.Add(f1);
gv.Columns.Add(f2);
gv.DataSource = list;
gv.DataBind();


Also create a web user control EMailTemplate, and put the hyperlink field
into it (see below)
(the Control tag might differ according Your application name)
--------------------------------------- Contents of EMailTemplate.ascx

<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="EMailTemplate.ascx.cs"
Inherits="YourWebApplication.EMailTemplate" %>

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#
Eval("EMail","mailto:{0}") %>' > <%# Eval("EMail") %> </asp:HyperLink>

Hope You find this useful.
-Zsolt


"HRsoft Informática" <> wrote in
message news:C4B3D39C-E565-455C-BC56-...
> Thanks for your response. But I need to create dynamically, on .VB 2008. I
> try this:
>
> Dim coluna11 As New HyperLinkField
>
> coluna11.DataTextField = "s_email"
> coluna11.HeaderText = "Email"
> coluna11.Text = "<%# Eval('s_Email') %>"
> coluna11.NavigateUrl = "<%# Eval('s_Email', 'mailto:{0}') %>"
> 'coluna11.DataNavigateUrlFields = "s_email"
> coluna11.ItemStyle.Wrap = False
>
> With this code, the content of the column change color to hyperlink color
> (
> according to .CSS), but no redirect or link to outlook, etc, ie, nothing
> happens.
>
> --
> Hércules
> HRsoft Informática - Rio de Janeiro - Brasil
> http://www.hrsoft.com.br
>
>
>
> "Mark Rae [MVP]" wrote:
>
>> "HRsoft Informática" <> wrote
>> in
>> message news:C98B76D8-A913-4EF8-B5F2-...
>>
>> > I need this column, an email, hyperlinked like: mailtothe content of
>> > the
>> > column)

>>
>> http://dotnetspidor.blogspot.com/200...ddress-in.html
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net
>>
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink Dave ASP .Net Datagrid Control 0 10-21-2006 07:48 PM
How to assign a column of URLs to Hyperlink Column of a DataGrid c =?Utf-8?B?ZGF2aWQ=?= ASP .Net 11 07-17-2006 07:20 PM
HyperLink Column and Button Column in a DataGrid =?Utf-8?B?V2FyYW4=?= ASP .Net 0 08-09-2005 12:00 AM



Advertisments