Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView - Hyperlink

Reply
Thread Tools

GridView - Hyperlink

 
 
Paul W Smith
Guest
Posts: n/a
 
      10-19-2007
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("Wk ts1"),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>


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      10-19-2007
On Oct 19, 6:53 pm, "Paul W Smith" <(E-Mail Removed)> 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("Wk ts1"),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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink Dave ASP .Net Datagrid Control 0 10-21-2006 07:48 PM
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
Dynamically Hyperlink and Event Handler for the Hyperlink ? Ken ASP .Net Datagrid Control 1 08-15-2003 11:38 PM



Advertisments