Connecting Tech Pros Worldwide Help | Site Map

how to use Eval with mailto?

Arvan
Guest
 
Posts: n/a
#1: May 25 '06
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 to use eval with control HyperLink?

<asp:HyperLink runat="server" id="email" NavigateUrl='mailto:<%#
Eval("Email") %>'>Email</asp:HyperLink>

Please watch property NavigateUrl.when i use mailto,there is no syntax
error.but i debug it , i saw that hyperlink's navigateurl didn't bind
datafield Email.how to use eval with mailto?


Nathan Sokalski
Guest
 
Posts: n/a
#2: May 25 '06

re: how to use Eval with mailto?


When you want the output of an Eval to be something other than the exact
data from the datasource, do something like this:


<asp:HyperLink id="lnkEmail" runat="server" text='<%#
DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
%>'></asp:HyperLink>


Notice that in the Eval used in the NavigateUrl there are three parameters:

Container (this will always be the same, do not change it)
"DataItem.email"
"MAILTO:{0}"

In the last parameter, create a string which formats the output. Place {0}
wherever you want the data from the datasource to appear. For example, in my
example, you would get something like:

MAILTO:njsokalski@hotmail.com

For more detail, see the documentation. If you have any questions, feel free
to ask and I will do my best to help. Good Luck!
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Arvan" <esato@126.com> wrote in message
news:O73jXn5fGHA.1792@TK2MSFTNGP03.phx.gbl...[color=blue]
> 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 to use eval with control HyperLink?
>
> <asp:HyperLink runat="server" id="email" NavigateUrl='mailto:<%#
> Eval("Email") %>'>Email</asp:HyperLink>
>
> Please watch property NavigateUrl.when i use mailto,there is no syntax
> error.but i debug it , i saw that hyperlink's navigateurl didn't bind
> datafield Email.how to use eval with mailto?
>[/color]


Arvan
Guest
 
Posts: n/a
#3: May 25 '06

re: how to use Eval with mailto?


Thank you very much!!!

"Nathan Sokalski" <njsokalski@hotmail.com> 写入消息新闻:eOQ2Nr6fGHA.2032@TK2MSFTNGP02.phx.gbl ...[color=blue]
> When you want the output of an Eval to be something other than the exact
> data from the datasource, do something like this:
>
>
> <asp:HyperLink id="lnkEmail" runat="server" text='<%#
> DataBinder.Eval(Container, "DataItem.email") %>' NavigateUrl='<%#
> DataBinder.Eval(Container, "DataItem.email","MAILTO:{0}")
> %>'></asp:HyperLink>
>
>
> Notice that in the Eval used in the NavigateUrl there are three
> parameters:
>
> Container (this will always be the same, do not change it)
> "DataItem.email"
> "MAILTO:{0}"
>
> In the last parameter, create a string which formats the output. Place {0}
> wherever you want the data from the datasource to appear. For example, in
> my example, you would get something like:
>
> MAILTO:njsokalski@hotmail.com
>
> For more detail, see the documentation. If you have any questions, feel
> free to ask and I will do my best to help. Good Luck!
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
> "Arvan" <esato@126.com> wrote in message
> news:O73jXn5fGHA.1792@TK2MSFTNGP03.phx.gbl...[color=green]
>> 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 to use eval with control HyperLink?
>>
>> <asp:HyperLink runat="server" id="email" NavigateUrl='mailto:<%#
>> Eval("Email") %>'>Email</asp:HyperLink>
>>
>> Please watch property NavigateUrl.when i use mailto,there is no syntax
>> error.but i debug it , i saw that hyperlink's navigateurl didn't bind
>> datafield Email.how to use eval with mailto?
>>[/color]
>
>[/color]


Closed Thread