When you want the output of an Eval to be something other than the exact
data from the datasource, do something like this:
<asp:HyperLin k 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:nj****** **@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
nj********@hotm ail.com http://www.nathansokalski.com/
"Arvan" <es***@126.co m> wrote in message
news:O7******** ******@TK2MSFTN GP03.phx.gbl...
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:HyperLin k runat="server" id="email" NavigateUrl='ma ilto:<%#
Eval("Email") %>'>Email</asp:HyperLink>
Please watch property NavigateUrl.whe n 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?