Problem setting NavigateUrl's in DataList (hyperlink)

V

VB Programmer

I have a datalist with a hyperlink in the Item Template.

When I set the NavigateUrl simply to this, the databound CategoryId shows up
fine:
<asp:HyperLink id=hlLink runat="server"
NavigateUrl='<%#Container.DataItem("CategoryId")%>'>
<%# Container.DataItem("CategoryName") %>
</asp:HyperLink>&nbsp;


When I try to add it as a querystring it doesn't show up correctly. For
example, if I set NavigateUrl to this:
NavigateUrl='Shop.aspx?CategoryId=<%#Container.DataItem("CategoryId")%>'>

The URL address is this:
Shop.aspx?CategoryId=<%#Container.DataItem("CategoryId")%>

Any ideas on how to fix this?

Thanks!
 
V

VB Programmer

Figured it out:
NavigateUrl='<%#"Shop.aspx?CategoryId=" &
DataBinder.Eval(Container.DataItem, "CategoryId")%>'>
Thanks y'all!
 
S

Siva M

Or like this:

NavigateUrl='<%= DataBinder.Eval (Container.DataItem, "CategoryId",
"shop.aspx?categoryId={0}") %>'

I have a datalist with a hyperlink in the Item Template.

When I set the NavigateUrl simply to this, the databound CategoryId shows up
fine:
<asp:HyperLink id=hlLink runat="server"
NavigateUrl='<%#Container.DataItem("CategoryId")%>'>
<%# Container.DataItem("CategoryName") %>
</asp:HyperLink>&nbsp;


When I try to add it as a querystring it doesn't show up correctly. For
example, if I set NavigateUrl to this:
NavigateUrl='Shop.aspx?CategoryId=<%#Container.DataItem("CategoryId")%>'>

The URL address is this:
Shop.aspx?CategoryId=<%#Container.DataItem("CategoryId")%>

Any ideas on how to fix this?

Thanks!
 

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,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top