W
William LaMartin
I have a gridview (with no properties set) on an aspx page which I populate
from an XML file with the code below.
The data in the XML file looks like this
<description>National Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Architecture</category>
Can anyone tell me why the other two columns are displayed, but the
hyperlink column does not display in the grid?
The code:
Dim DS As New Data.DataSet
DS.ReadXml(Server.MapPath(".") & "\data\Links.xml")
Dim dt As New Data.DataTable
Dim dr As Data.DataRow
Dim hl As New HyperLink
Dim i As Integer
dt.Columns.Add(New Data.DataColumn("Description", GetType(String)))
dt.Columns.Add(New Data.DataColumn("URL", GetType(HyperLink)))
dt.Columns.Add(New Data.DataColumn("Category", GetType(String)))
For i = 0 To DS.Tables(0).Rows.Count - 1
dr = dt.NewRow
dr("Description") = DS.Tables(0).Rows.Item(i).Item(0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Rows.Item(i).Item(1) 'the link's URL
hl.Text = DS.Tables(0).Rows.Item(i).Item(0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Rows.Item(i).Item(2) 'The link's category
dt.Rows.Add(dr)
Next
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
from an XML file with the code below.
The data in the XML file looks like this
<description>National Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Architecture</category>
Can anyone tell me why the other two columns are displayed, but the
hyperlink column does not display in the grid?
The code:
Dim DS As New Data.DataSet
DS.ReadXml(Server.MapPath(".") & "\data\Links.xml")
Dim dt As New Data.DataTable
Dim dr As Data.DataRow
Dim hl As New HyperLink
Dim i As Integer
dt.Columns.Add(New Data.DataColumn("Description", GetType(String)))
dt.Columns.Add(New Data.DataColumn("URL", GetType(HyperLink)))
dt.Columns.Add(New Data.DataColumn("Category", GetType(String)))
For i = 0 To DS.Tables(0).Rows.Count - 1
dr = dt.NewRow
dr("Description") = DS.Tables(0).Rows.Item(i).Item(0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Rows.Item(i).Item(1) 'the link's URL
hl.Text = DS.Tables(0).Rows.Item(i).Item(0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Rows.Item(i).Item(2) 'The link's category
dt.Rows.Add(dr)
Next
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()