Reputation: 320
How can I set the text value of a hyperlink to a the page or image name within a databound url string. Something like:
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("attachUrl")%>' Text="<%# System.IO.Path.GetFileName(Eval("attachUrl"))%>"></asp:HyperLink>
The NavigateURL works but not the Text.
Upvotes: 1
Views: 1072
Reputation: 82096
That's because you break the string when you add the "
in the Eval
method. Use apostrophe's on the outer text so you can use double-quotes for the Eval
method i.e.
Text='<%# System.IO.Path.GetFileName(Eval("attachUrl").ToString())%>'
Upvotes: 3