473,626 Members | 3,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hyperlink Column not displaying

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>Na tional Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Archi tecture</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(Serv er.MapPath(".") & "\data\Links.xm l")
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 ("Descriptio n", GetType(String) ))
dt.Columns.Add( New Data.DataColumn ("URL", GetType(HyperLi nk)))
dt.Columns.Add( New Data.DataColumn ("Category", GetType(String) ))

For i = 0 To DS.Tables(0).Ro ws.Count - 1

dr = dt.NewRow
dr("Description ") = DS.Tables(0).Ro ws.Item(i).Item (0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Ro ws.Item(i).Item (1) 'the link's URL
hl.Text = DS.Tables(0).Ro ws.Item(i).Item (0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Ro ws.Item(i).Item (2) 'The link's category
dt.Rows.Add(dr)
Next

Me.GridView1.Da taSource = dt
Me.GridView1.Da taBind()
Sep 18 '06 #1
3 3123
Why don't you do this in design mode ?

"William LaMartin" <la******@tampa bay.rr.comwrote in :
Og************* *@TK2MSFTNGP03. phx.gbl...
>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>Na tional Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Archi tecture</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(Serv er.MapPath(".") & "\data\Links.xm l")
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 ("Descriptio n", GetType(String) ))
dt.Columns.Add( New Data.DataColumn ("URL", GetType(HyperLi nk)))
dt.Columns.Add( New Data.DataColumn ("Category", GetType(String) ))

For i = 0 To DS.Tables(0).Ro ws.Count - 1

dr = dt.NewRow
dr("Description ") = DS.Tables(0).Ro ws.Item(i).Item (0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Ro ws.Item(i).Item (1) 'the link's URL
hl.Text = DS.Tables(0).Ro ws.Item(i).Item (0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Ro ws.Item(i).Item (2) 'The link's category
dt.Rows.Add(dr)
Next

Me.GridView1.Da taSource = dt
Me.GridView1.Da taBind()

Sep 18 '06 #2
Because for some reason when I try to add my XML file as an XMLDataSource in
design mode I receive the following message:

There was an error rendering the control.
The data source for GridView with id 'GridView1' did not have any properties
or attributes from which to generate columns. Ensure that your data source
has content.

In researching this, I have read that instead of the structure my XML file
has, what is wanted is for each item to have attributes instead of elements.
I haven't looked into doing this, though.

Furthermore, I have found it more flexible to generate data connections in
code. And I am sure there is a way to get the hyperlink column to display
this way--I just haven't found it.
"Martin CLAVREUIL" <az****@azerty. comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Why don't you do this in design mode ?

"William LaMartin" <la******@tampa bay.rr.comwrote in :
Og************* *@TK2MSFTNGP03. phx.gbl...
>>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>N ational Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Arch itecture</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(Ser ver.MapPath("." ) & "\data\Links.xm l")
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 ("Descriptio n", GetType(String) ))
dt.Columns.Add (New Data.DataColumn ("URL", GetType(HyperLi nk)))
dt.Columns.Add (New Data.DataColumn ("Category", GetType(String) ))

For i = 0 To DS.Tables(0).Ro ws.Count - 1

dr = dt.NewRow
dr("Description ") = DS.Tables(0).Ro ws.Item(i).Item (0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Ro ws.Item(i).Item (1) 'the link's URL
hl.Text = DS.Tables(0).Ro ws.Item(i).Item (0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Ro ws.Item(i).Item (2) 'The link's category
dt.Rows.Add(dr)
Next

Me.GridView1.D ataSource = dt
Me.GridView1.D ataBind()


Sep 18 '06 #3
The solution was to do a little hand coding on the source page of the aspx
file containing the GridView as below to create the hyperlink column. Then
create a dataset from the XML file as a datasource for the GridView and
importantly set AutoGenerateCol umns=False to keep from getting redundant
data. (The field names in the XML file are and dataset are description, URL
and Category)

<asp:GridView ID="GridView1" runat="server" Style="z-index: 100; left: 17px;
position: absolute;
top: 82px">

<Columns>
<asp:HyperLinkF ield
HeaderText="Sit e"
DataTextField=" description"
DataTextFormatS tring="{0}"
DataNavigateUrl Fields="URL"
DataNavigateUrl FormatString="{ 0}"
Target="_Blank"
/>
<asp:BoundFie ld DataField="Cate gory" HeaderText="Cat egory">
</Columns>
</asp:GridView>
"William LaMartin" <la******@tampa bay.rr.comwrote in message
news:Og******** ******@TK2MSFTN GP03.phx.gbl...
>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>Na tional Trust for Historic Preservation</description>
<URL>http://www.nthp.org/</URL>
<category>Archi tecture</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(Serv er.MapPath(".") & "\data\Links.xm l")
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 ("Descriptio n", GetType(String) ))
dt.Columns.Add( New Data.DataColumn ("URL", GetType(HyperLi nk)))
dt.Columns.Add( New Data.DataColumn ("Category", GetType(String) ))

For i = 0 To DS.Tables(0).Ro ws.Count - 1

dr = dt.NewRow
dr("Description ") = DS.Tables(0).Ro ws.Item(i).Item (0) 'The link's
description
hl.NavigateUrl = DS.Tables(0).Ro ws.Item(i).Item (1) 'the link's URL
hl.Text = DS.Tables(0).Ro ws.Item(i).Item (0) 'description
hl.Target = "_Blank"
dr("URL") = hl
dr("Category") = DS.Tables(0).Ro ws.Item(i).Item (2) 'The link's category
dt.Rows.Add(dr)
Next

Me.GridView1.Da taSource = dt
Me.GridView1.Da taBind()

Sep 18 '06 #4

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

Similar topics

6
2939
by: epigram | last post by:
I'm using the DataGrid with AutoGenerateColumns set to false and choosing which columns I want in the grid by using the <Columns> attribute. What I want to do is to create a hyperlink out of one of the columns that I am displaying, but in order to build this link, I need a value that is in my SELECT clause, but is not being displayed via a BoundColumn. Say I have a query: SELECT ID, Name FROM Companies Here, ID is the PK. I am only...
3
15404
by: Tim::.. | last post by:
I currently have the following datagrid but want to turn the name and email column into a hyperlink in the codebehind! Can someone please tell me how I achieve this! Thanks Private Sub createTable() Dim tbcontacts As DataTable = New DataTable("contacts") tbcontacts.Columns.Add(" ", System.Type.GetType("System.String"))
0
1256
by: Waran | last post by:
Hi, In a datagrid I am displaying 2 columns. One is a Hyperlink Colum and the other is a Button Column. The values for the hyperlink columns are fetched from the database and its a url. When I click the Download button I am taking the URL value from the Hyperlink column (using CType(E.Item.Cells(0).Controls(0), HyperLink).NavigateUrl ).I am doing some validations on this Button Click event.Its working fine. Now I need to perform the...
10
1925
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it. Do you have ideas about it? Thanks.
3
3536
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
1
1370
by: serge calderara | last post by:
Dear all, I am building an ASP 1.1 applciation collecting data from an SQL server database. In one table field, users will have possibility to introduced a file path (attached document) What I would like to do is to display in a datagrid column, a picture visible when the File path column is not empty and that path is valid, and then create an hyperlink on that picture pointing to the file.
4
4118
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 detail records, it displays a hyperlink that then takes the user to the details page. If a master record doesn't have any children, I just want it to display its ID with no hyperlink.
3
2510
by: Uriah Piddle | last post by:
Hi Gang, in VS 2005, I have an Asp:Hyperlink in a GridView TemplateField. I am trying to figure out how to make the text of the hyperlink wrap to the next line if it is too long. Setting the Width prop of the hyperlink or the Wrap prop of either the GridView itself or the ItemTemplate does not work. Thanks for any ideas. Steve
1
7161
by: Valli | last post by:
Hi, I need to display an hyperlink column in gridview where if the user clicks that column the page should move to the selected page. I have got help from this group & started using template field. After using this, I couldnt see a column supporting hyperlink. In the gridviews first column header, there appears an hyperlink with the first record link displaying. That also only in header overwriting with the first column caption.
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.