HyperLink in DataList?

Discussion in 'ASP .Net Datagrid Control' started by rockdale, Jun 27, 2006.

  1. rockdale

    rockdale Guest

    nside itemtemplate of my DataList I have

    <td>
    <asp:HyperLink runat="server" Text='<%#
    DataBinder.Eval(Container.DataItem, "funcDesc") %>'
    NavigateUrl='../Default.aspx?fID=<%#
    DataBinder.Eval(Container.DataItem,"funcId") %>'
    ID="Hyperlink1"></asp:HyperLink>
    </td>
    <td>
    <a href='Default.aspx?fID=<%# DataBinder.Eval(Container.DataItem,
    "funcId") %>' class =normalLink><%# DataBinder.Eval(Container.DataItem,
    "funcDesc") %>
    </a>
    </td>


    The first one (<asp:hyperlink ) does interpret url correctly, it
    interpret as
    Default.aspx?fID=<%#fID=<%#
    DataBinder.Eval(Container.DataItem,"funcId")%>

    The second (<a href ) is correct
    Default.aspx?fID=1

    What did I do wrong with the first asp:hyperlink?

    How can I get it work?

    Thanks a lot

    -rockdale
    rockdale, Jun 27, 2006
    #1
    1. Advertising

  2. When the NavigateUrl property (or any property) of a HyperLink in a DataList
    Template is more than just the data being databound, do it like the
    following:


    NavigateUrl='<%#
    DataBinder.Eval(Container.DataItem,"funcId","../Default.aspx?fID={0}") %>'


    The {0} in the last parameter of DataBinder.Eval will be replaced with the
    data being databound. This problem stumped me when I first ran into it also,
    but as you can see, the solution is really very simple. If you have any
    questions, let me know. Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "rockdale" <> wrote in message
    news:...
    > nside itemtemplate of my DataList I have
    >
    > <td>
    > <asp:HyperLink runat="server" Text='<%#
    > DataBinder.Eval(Container.DataItem, "funcDesc") %>'
    > NavigateUrl='../Default.aspx?fID=<%#
    > DataBinder.Eval(Container.DataItem,"funcId") %>'
    > ID="Hyperlink1"></asp:HyperLink>
    > </td>
    > <td>
    > <a href='Default.aspx?fID=<%# DataBinder.Eval(Container.DataItem,
    > "funcId") %>' class =normalLink><%# DataBinder.Eval(Container.DataItem,
    > "funcDesc") %>
    > </a>
    > </td>
    >
    >
    > The first one (<asp:hyperlink ) does interpret url correctly, it
    > interpret as
    > Default.aspx?fID=<%#fID=<%#
    > DataBinder.Eval(Container.DataItem,"funcId")%>
    >
    > The second (<a href ) is correct
    > Default.aspx?fID=1
    >
    > What did I do wrong with the first asp:hyperlink?
    >
    > How can I get it work?
    >
    > Thanks a lot
    >
    > -rockdale
    >
    Nathan Sokalski, Jun 27, 2006
    #2
    1. Advertising

  3. rockdale

    rockdale Guest

    Thank you, I always saw some example of {0} but never really tried to
    know what it is.


    Thanks
    -Rockdale
    Nathan Sokalski wrote:
    > When the NavigateUrl property (or any property) of a HyperLink in a DataList
    > Template is more than just the data being databound, do it like the
    > following:
    >
    >
    > NavigateUrl='<%#
    > DataBinder.Eval(Container.DataItem,"funcId","../Default.aspx?fID={0}") %>'
    >
    >
    > The {0} in the last parameter of DataBinder.Eval will be replaced with the
    > data being databound. This problem stumped me when I first ran into it also,
    > but as you can see, the solution is really very simple. If you have any
    > questions, let me know. Good Luck!
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "rockdale" <> wrote in message
    > news:...
    > > nside itemtemplate of my DataList I have
    > >
    > > <td>
    > > <asp:HyperLink runat="server" Text='<%#
    > > DataBinder.Eval(Container.DataItem, "funcDesc") %>'
    > > NavigateUrl='../Default.aspx?fID=<%#
    > > DataBinder.Eval(Container.DataItem,"funcId") %>'
    > > ID="Hyperlink1"></asp:HyperLink>
    > > </td>
    > > <td>
    > > <a href='Default.aspx?fID=<%# DataBinder.Eval(Container.DataItem,
    > > "funcId") %>' class =normalLink><%# DataBinder.Eval(Container.DataItem,
    > > "funcDesc") %>
    > > </a>
    > > </td>
    > >
    > >
    > > The first one (<asp:hyperlink ) does interpret url correctly, it
    > > interpret as
    > > Default.aspx?fID=<%#fID=<%#
    > > DataBinder.Eval(Container.DataItem,"funcId")%>
    > >
    > > The second (<a href ) is correct
    > > Default.aspx?fID=1
    > >
    > > What did I do wrong with the first asp:hyperlink?
    > >
    > > How can I get it work?
    > >
    > > Thanks a lot
    > >
    > > -rockdale
    > >
    rockdale, Jun 27, 2006
    #3
    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. Arjen
    Replies:
    0
    Views:
    501
    Arjen
    Aug 4, 2003
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,833
  3. davetichenor
    Replies:
    1
    Views:
    796
    Eliyahu Goldin
    Oct 30, 2006
  4. Ken
    Replies:
    1
    Views:
    355
    Alvin Bruney
    Aug 16, 2003
  5. Dave
    Replies:
    0
    Views:
    919
Loading...

Share This Page