Re: Repeater and Eval
Chris Anderson <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
> From: Discussion of building .NET applications targeted for the Web > [mailto:[email protected]] On Behalf Of Gabriel > Sent: 26 April 2007 12:31 > To: [email protected] > Subject: Re: [DOTNET-WEB] Repeater and Eval > > On 4/26/07, Chris Anderson <[email protected]> wrote: > > > > <asp:HyperLink > > runat="server" > > NavigateUrl='<%# Eval("Url") %>' > > Visible='<%# (!String.IsNullOrEmpty(Eval("Url"))).ToString() %>' > > > > > <%# Eval("Title") %></asp:HyperLink> > > > > Not work :(. > > It's the second hyperlink in the repeater I need to hide this section : > > > <ItemTemplate> > <li> > <asp:HyperLink > runat="server" > NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink> > </li> > </ItemTemplate> That's the hyperlink I (and I think everyone else that has responded) is trying to hide. You cannot hide an ItemTemplate (because it's just a template), so you need to either hide the list item <li> or the hyperlink itself for a specific bound item. If you really only want to hide the hyperlink, replacing the hyperlink with this works (I tested): <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>' Visible='<%# (!String.IsNullOrEmpty((string)Eval("Url"))) %>' > <%# Eval("Title") %> </asp:HyperLink> (I missed the cast to a string in my above code, which is why it probably failed last time) If you *actually* want the list item (the <li>)removed from the <ul> list, then you need to use similar logic to hide the <li> tag: <li runat="server" visible='<%# (!String.IsNullOrEmpty((string)Eval("Url"))) %>'> <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Url") %>' > <%# Eval("Title") %> </asp:HyperLink> </li> =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com