Problem setting NavigateUrl's in DataList (hyperlink)

Discussion in 'ASP .Net' started by VB Programmer, Nov 15, 2005.

  1. 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!
    VB Programmer, Nov 15, 2005
    #1
    1. Advertising

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

    "VB Programmer" <> wrote in message
    news:...
    >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!
    >
    VB Programmer, Nov 15, 2005
    #2
    1. Advertising

  3. VB Programmer

    Siva M Guest

    Or like this:

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

    "VB Programmer" <> wrote in message
    news:...
    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!
    Siva M, Nov 15, 2005
    #3
  4. Thanks Siva!
    "Siva M" <> wrote in message
    news:uydKf%...
    > Or like this:
    >
    > NavigateUrl='<%= DataBinder.Eval (Container.DataItem, "CategoryId",
    > "shop.aspx?categoryId={0}") %>'
    >
    > "VB Programmer" <> wrote in message
    > news:...
    > 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!
    >
    >
    >
    VB Programmer, Nov 16, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boban Dragojlovic
    Replies:
    3
    Views:
    3,030
    vMike
    Oct 29, 2003
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,865
  3. Tomek R.
    Replies:
    7
    Views:
    8,189
    Sobot
    Feb 13, 2009
  4. gerry

    asp:Hyperlink NavigateUrl problem

    gerry, Jan 18, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    8,601
    Sobot
    Feb 13, 2009
  5. Christoph Schuster

    Problem with Hyperlink.NavigateURL="../../" in WebControls

    Christoph Schuster, Jul 21, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    285
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
Loading...

Share This Page