Murray Brown
asked on
ASP.net Hyperlink in GridView as part of the data set
Hi
I am using the following code to populate a GridView with a dataset. Instead of outting text in the column "Title", I want to put a hyperlink to a certain URL. How would I convert the line
dr("Title") = "Winter"
to a hyperlink that links to "www.rosebankguesthouse.com"
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.DataBind()
End Sub
Function GetData() As DataTable
' This method creates a DataTable with four rows. Each row has the
' following schema:
' PictureID int
' PictureURL string
' Title string
' DateAdded datetime
Dim dt As New DataTable()
' define the table's schema
dt.Columns.Add(New DataColumn("PictureID", GetType(Integer)))
dt.Columns.Add(New DataColumn("PictureURL", GetType(String)))
dt.Columns.Add(New DataColumn("Title", GetType(String)))
dt.Columns.Add(New DataColumn("DateAdded", GetType(DateTime)))
' Create the four records
Dim dr As DataRow = dt.NewRow()
dr("PictureID") = 1
dr("PictureURL") = ResolveUrl("~/Resources/Cr aighall_Ha nds_On_Ret reat.jpg")
dr("Title") = "zBlue Hills"
dr("DateAdded") = New DateTime(2005, 1, 15)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 2
dr("PictureURL") = ResolveUrl("~/Resources/Cr aighall_Pa rk_Abbey_G uest_House .jpg")
dr("Title") = "Sunset"
dr("DateAdded") = New DateTime(2005, 1, 21)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 3
dr("PictureURL") = _
ResolveUrl("~/Resources/Me lrose_Melr ose_Place_ Guest_Lodg e.jpg")
dr("Title") = "Water Lilies"
dr("DateAdded") = New DateTime(2005, 2, 1)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 4
dr("PictureURL") = ResolveUrl("~/Resources/Me lrose_The_ Peech_Hote l.jpg")
dr("Title") = "Winter"
dr("DateAdded") = New DateTime(2005, 2, 18)
dt.Rows.Add(dr)
Return dt
End Function
I am using the following code to populate a GridView with a dataset. Instead of outting text in the column "Title", I want to put a hyperlink to a certain URL. How would I convert the line
dr("Title") = "Winter"
to a hyperlink that links to "www.rosebankguesthouse.com"
Thanks
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.DataBind()
End Sub
Function GetData() As DataTable
' This method creates a DataTable with four rows. Each row has the
' following schema:
' PictureID int
' PictureURL string
' Title string
' DateAdded datetime
Dim dt As New DataTable()
' define the table's schema
dt.Columns.Add(New DataColumn("PictureID", GetType(Integer)))
dt.Columns.Add(New DataColumn("PictureURL", GetType(String)))
dt.Columns.Add(New DataColumn("Title", GetType(String)))
dt.Columns.Add(New DataColumn("DateAdded", GetType(DateTime)))
' Create the four records
Dim dr As DataRow = dt.NewRow()
dr("PictureID") = 1
dr("PictureURL") = ResolveUrl("~/Resources/Cr
dr("Title") = "zBlue Hills"
dr("DateAdded") = New DateTime(2005, 1, 15)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 2
dr("PictureURL") = ResolveUrl("~/Resources/Cr
dr("Title") = "Sunset"
dr("DateAdded") = New DateTime(2005, 1, 21)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 3
dr("PictureURL") = _
ResolveUrl("~/Resources/Me
dr("Title") = "Water Lilies"
dr("DateAdded") = New DateTime(2005, 2, 1)
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("PictureID") = 4
dr("PictureURL") = ResolveUrl("~/Resources/Me
dr("Title") = "Winter"
dr("DateAdded") = New DateTime(2005, 2, 18)
dt.Rows.Add(dr)
Return dt
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER