I'm looking for the syntax for using Eval with a hyperlink

17 views Asked by At

I have a hyperlink in a repeater:

                        <asp:HyperLink ID="hl_User" runat="server" 
                            NavigateUrl='<%# Eval("CheckoutID", "CheckoutForm.aspx?Checkout={0}")  %>' 
                            Text='<%# Eval("UserName") %>'>
                        </asp:HyperLink> 

The repeater has three columns. Shows a list of items, the user who checked it out and the number of days it was checked out.

Problem is if no one have checked an item out the hyperlink is not there and I would prefer to change the NavigateURL to something like <%# Eval("ItemID", "NewCheckoutForm.aspx?Item={0}" with a text of "Create new Checkout"

I can't seem to figure out the proper way to do the if statement in this case.

Normally I would address this in the code behind but honestly I haven't coded in more than five years and am having a bit of difficulty remembering how.

If someone could direct me to a nice page that explains Eval thoroughly I would appreciate it.

Thanks, Mike

I tried:

         <asp:HyperLink ID="hl_User" runat="server" 
                NavigateUrl='<%# Eval("CheckoutID", "CheckoutForm.aspx?Checkout={0}")  %>' 
                Text='<%# ((string)Eval("UserName")) != null, "Checkout Item" %>'>
         </asp:HyperLink> 
0

There are 0 answers