HyperLink in DataList?

R

rockdale

nside itemtemplate of my DataList I have

<td>
<asp:HyperLink runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "funcDesc") %>'
NavigateUrl='../Default.aspx?fID=<%#
DataBinder.Eval(Container.DataItem,"funcId") %>'
ID="Hyperlink1"></asp:HyperLink>
</td>
<td>
<a href='Default.aspx?fID=<%# DataBinder.Eval(Container.DataItem,
"funcId") %>' class =normalLink><%# DataBinder.Eval(Container.DataItem,
"funcDesc") %>
</a>
</td>


The first one (<asp:hyperlink ) does interpret url correctly, it
interpret as
Default.aspx?fID=<%#fID=<%#
DataBinder.Eval(Container.DataItem,"funcId")%>

The second (<a href ) is correct
Default.aspx?fID=1

What did I do wrong with the first asp:hyperlink?

How can I get it work?

Thanks a lot

-rockdale
 
N

Nathan Sokalski

When the NavigateUrl property (or any property) of a HyperLink in a DataList
Template is more than just the data being databound, do it like the
following:


NavigateUrl='<%#
DataBinder.Eval(Container.DataItem,"funcId","../Default.aspx?fID={0}") %>'


The {0} in the last parameter of DataBinder.Eval will be replaced with the
data being databound. This problem stumped me when I first ran into it also,
but as you can see, the solution is really very simple. If you have any
questions, let me know. Good Luck!
 
R

rockdale

Thank you, I always saw some example of {0} but never really tried to
know what it is.


Thanks
-Rockdale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top