Joe W
Joe W

Reputation: 1567

How do I use asp:hyperlink with databinding

I thought I had this one pretty good, but I just keep running into an error

Am I doing anything wrong in the code that you can see?

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format(~/storefront.aspx?CatalogID={0}&ProductID={1}",DataBinder.Eval(Container.DataItem, "CatalogID"),DataBinder.Eval(Container.DataItem,"CustItem")) %>' >

Is there another method I could use any help on the matter is appreciated. Thank you

Upvotes: 2

Views: 7241

Answers (1)

James Johnson
James Johnson

Reputation: 46057

You're missing an open quote in the String.Format function. Try this instead:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("~/storefront.aspx?CatalogID={0}&ProductID={1}", Eval("CatalogID"), Eval("CustItem"))%>'></asp:HyperLink>

Upvotes: 2

Related Questions