GridView - Hyperlink

Discussion in 'ASP .Net' started by Paul W Smith, Oct 19, 2007.

  1. Paul W Smith

    Paul W Smith Guest

    The text below is a GridView I am trying to use to display some data from a
    database. I am using one templatefield of grid because I want the contents
    of the record fields to appear on three different lines.

    Everything works except I now want to add an image with which acts as a
    hyperlink to another page. The querystring to the new page is a field from
    the database. What I cannot get right is the syntax to build the Hyperlink
    to the required page using thr NavigateUrl.

    Can anyone tell me if what I am trying to do is possible? Is it possible to
    build up a NavigateUrl using Eval("FixtureID"), something along the lines of
    Scoreheet.aspx?FixID=Eval("fixtureID")


    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="AccessDataSource1">
    <Columns>
    <asp:TemplateField ShowHeader="False">
    <ItemTemplate>
    <table>
    <tr>
    <td>
    Played at
    <%#HomeTeamName(Eval("Home1"),Eval("Team1"),Eval("Team2"))%>
    </td>
    <td>
    <%#Eval("MatchResultText")%>
    </td>
    <td rowspan="3">
    <%#Eval("FixtureID")%>
    '==========================================================================
    <asp:HyperLink ID="HyperLink1" runat="server"
    ImageUrl="~/Images/Scoresheet.GIF"
    NavigateUrl="<%# "Scoresheet.aspx?FixID=" &
    Eval("FixtureID"))%>"
    </asp:HyperLink>
    '==========================================================================
    </td>
    </tr>
    <tr>
    <td>
    <%#
    CricketScore(Eval("Team1"),Eval("Score1"),Eval("Wkts1"),Eval("Dec"),Eval("Overs1"))%>
    </td>
    <td>
    <%#
    TeamGamePoints(Eval("Team1"),Eval("Points1"))%>
    </td>
    </tr>
    <tr>
    <td>
    <%#CricketScore(Eval("Team2"), Eval("Score2"),
    Eval("Wkts2"), False, Eval("Overs2"))%>
    </td>
    <td>
    <%#
    TeamGamePoints(Eval("Team2"),Eval("Points2"))%>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    <asp:GridView>
    Paul W Smith, Oct 19, 2007
    #1
    1. Advertising

  2. On Oct 19, 6:53 pm, "Paul W Smith" <> wrote:
    > The text below is a GridView I am trying to use to display some data from a
    > database. I am using one templatefield of grid because I want the contents
    > of the record fields to appear on three different lines.
    >
    > Everything works except I now want to add an image with which acts as a
    > hyperlink to another page. The querystring to the new page is a field from
    > the database. What I cannot get right is the syntax to build the Hyperlink
    > to the required page using thr NavigateUrl.
    >
    > Can anyone tell me if what I am trying to do is possible? Is it possible to
    > build up a NavigateUrl using Eval("FixtureID"), something along the lines of
    > Scoreheet.aspx?FixID=Eval("fixtureID")
    >
    > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    > DataSourceID="AccessDataSource1">
    > <Columns>
    > <asp:TemplateField ShowHeader="False">
    > <ItemTemplate>
    > <table>
    > <tr>
    > <td>
    > Played at
    > <%#HomeTeamName(Eval("Home1"),Eval("Team1"),Eval("Team2"))%>
    > </td>
    > <td>
    > <%#Eval("MatchResultText")%>
    > </td>
    > <td rowspan="3">
    > <%#Eval("FixtureID")%>
    > '==========================================================================
    > <asp:HyperLink ID="HyperLink1" runat="server"
    > ImageUrl="~/Images/Scoresheet.GIF"
    > NavigateUrl="<%# "Scoresheet.aspx?FixID=" &
    > Eval("FixtureID"))%>"
    > </asp:HyperLink>
    > '==========================================================================
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <%#
    > CricketScore(Eval("Team1"),Eval("Score1"),Eval("Wkts1"),Eval("Dec"),Eval("O­vers1"))%>
    > </td>
    > <td>
    > <%#
    > TeamGamePoints(Eval("Team1"),Eval("Points1"))%>
    > </td>
    > </tr>
    > <tr>
    > <td>
    > <%#CricketScore(Eval("Team2"), Eval("Score2"),
    > Eval("Wkts2"), False, Eval("Overs2"))%>
    > </td>
    > <td>
    > <%#
    > TeamGamePoints(Eval("Team2"),Eval("Points2"))%>
    > </td>
    > </tr>
    > </table>
    > </ItemTemplate>
    > </asp:TemplateField>
    > </Columns>
    > <asp:GridView>



    <asp:HyperLink ID="HyperLink1" runat="server"
    ImageUrl="~/Images/Scoresheet.GIF"
    NavigateUrl='<%# "Scoresheet.aspx?FixID=" & Eval("FixtureID") %>' >
    </asp:HyperLink>
    Alexey Smirnov, Oct 19, 2007
    #2
    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. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,944
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  2. davetichenor
    Replies:
    1
    Views:
    804
    Eliyahu Goldin
    Oct 30, 2006
  3. Keith G Hicks
    Replies:
    3
    Views:
    749
    Keith G Hicks
    Feb 18, 2008
  4. Ken
    Replies:
    1
    Views:
    360
    Alvin Bruney
    Aug 16, 2003
  5. Dave
    Replies:
    0
    Views:
    923
Loading...

Share This Page