473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView - Hyperlink

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>
Oct 19 '07 #1
1 2506
On Oct 19, 6:53 pm, "Paul W Smith" <p...@NOSPAM.twelve.me.ukwrote:
The text below is a GridView I am trying to use to display some data froma
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 possibleto
build up a NavigateUrl using Eval("FixtureID"), something along the linesof
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>

Oct 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Carlos | last post by:
Hi all, I need a field that it is both databound, and hyperlink in a gridview. That is, the value is obtained from a query, and at the same time needs to point to a new page where will be used...
2
by: loga123 | last post by:
Hi All, I am using Link Button for DELETE on the gridview. When I click on DELETE link, I get the ArgumentOutOfRangeException. But...it deletes the record from table in the database. On...
1
by: willip | last post by:
I have a Gridview control with a Databound Hyperlink. e.g.: <asp:HyperLinkField HeaderText="MyTitle" DataNavigateUrlFields="MyID" DataNavigateUrlFormatString="~/ShowMe.aspx?MyID={0}"...
7
by: David | last post by:
Using ASP.Net 2.0 and VS 2005. I have a search page that has server controls, (textboxes, dropdownlists, etc.) that are used for searching and returning data in a GridView. One of the GridView...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
4
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a GridView that is displaying master records. Some of these records have child records. I would like to a column to my master GridView such that for each master record that has...
4
by: Jeff | last post by:
Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET GridView with paging and sorting. One of the columns of this Gridview is a template column (LinkButton). The data being...
1
by: suganya | last post by:
I have displayed the data from the DB to the GridView made a column in the GridView as HyperLink allowed paging by setting the Allow Paging Property to "True". By clicking on the page no link I have...
1
by: Author | last post by:
I got into trouble with this problem. The data I am presenting in a GridView control has a column called "Website". That data comes from a stored procedure in SQL Server 2000. Most of them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.