473,397 Members | 1,949 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,397 software developers and data experts.

Problem with hyperlink column in gridview

47
I have a gridview that has a hyperlink column. It gets the web address from a data source. This is all working as it should. The problem is when I click the web address, it doesn't go to the address. It's like it's trying to find the address locally. I know it probable has something to do with the url formatting, but not sure what needs to be done.

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="gvEmployeesBenefits" runat="server" DataSourceID="Benefits" Style="z-index: 100;
  2.     left: 0px; top: 0px" AutoGenerateColumns="False" BackColor="White" 
  3.     BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
  4.     GridLines="Horizontal" onrowdatabound="gvEmployeesBenefits_RowDataBound">
  5.     <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
  6.     <Columns>
  7.         <asp:CommandField ShowEditButton="True" />
  8.         <asp:BoundField DataField="BGAN8" HeaderText="Emp#" 
  9.             ReadOnly="True" Visible="False" />
  10.         <asp:BoundField DataField="BGPLAN" HeaderText="Plan" ReadOnly="True" 
  11.             Visible="False" />
  12.         <asp:BoundField DataField="BGAOPT" HeaderText="Option" ReadOnly="True" 
  13.             Visible="False" />
  14.         <asp:BoundField DataField="BAEXA" HeaderText="Plan Description" 
  15.             ReadOnly="True" />
  16.         <asp:BoundField DataField="BGEFT" HeaderText="Enrollment Date" 
  17.             ReadOnly="True" />
  18.         <asp:BoundField DataField="BAFDBA" HeaderText="BAFDBA" ReadOnly="True" 
  19.             Visible="False" />
  20.         <asp:BoundField DataField="BASDBA" HeaderText="BASDBA" ReadOnly="True" 
  21.             Visible="False" />
  22.         <asp:BoundField AccessibleHeaderText="RT" DataField="RT" 
  23.             DataFormatString="{0:N2}" HeaderText="RT" />
  24.         <asp:BoundField DataField="YTD" DataFormatString="{0:N2}" HeaderText="YTD" 
  25.             ReadOnly="True" />
  26.         <asp:HyperLinkField HeaderText="Website" DataNavigateUrlFields="Website" 
  27.             DataTextField="Website" />
  28.     </Columns>
  29.     <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
  30.     <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
  31.     <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
  32.     <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
  33.     <AlternatingRowStyle BackColor="#F7F7F7" />
  34. </asp:GridView>
May 5 '09 #1
9 6309
maliksleo
115 100+
@kimbred
I think you miss the DataNavigateUrlFormatString part from your hyperlinkField.
use the following code.
Expand|Select|Wrap|Line Numbers
  1. <asp:HyperLinkField HeaderText="Website" DataNavigateUrlFields="Website" 
  2.             DataTextField="Website" DataNavigateUrlFormatString="pagename?variable={0}"/>
maliksleo
May 6 '09 #2
the Gridview tries to locate the website locally unless there is http:// in front of the url, just www. doesnt really work
May 6 '09 #3
balame2004
142 100+
www should find it out in world wide web.
May 6 '09 #4
i have had occasions where it didnt figure it out, however, one can never be too safe right?
May 6 '09 #5
kimbred
47
When I put in DataNavigateUrlFormatString="pagename?variable={0} " I get the following.

"Illegal characters in path. "
May 6 '09 #6
Can you give an example of a url that is being bound?
May 6 '09 #7
kimbred
47
WWW.NEX-TECH.COM
If I put the http:// on the front, it works now, but you'd think just the site name would be enough. I'm kind of new to web applications so still learning.
May 6 '09 #8
i had this run in as well a while ago, one of the reasons i think is the parameters in asp like
people can use www. as a prefix for something else as well, hence the http:// (or ftp://) will make it see as an external website.

if you have something in which you can enter the field and store it you can do a check to see whether the user entered http://
May 6 '09 #9
kimbred
47
Will do. Thanks for your help/
May 6 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: jib | last post by:
How do I redirect a hyperlink column's URL when the URL doesn't exist? Is it possible to set a default URL for the Hyperlink button? Thanks, Jib
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
3
by: Matthias S. | last post by:
Hi, I've got a DataGrid which is displayed within a CustomerDetails page. The CustomerDetails data (including the data for the grid) is loaded using a QueryString (Item CustomerID) which is...
2
by: Jason | last post by:
I have a data grid with a hyperlink column. The hyperlink is created by a class that extracts the link from an XML Document. How can I populate the hyperlink column in the data grid with the...
10
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...
3
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...
3
by: William LaMartin | last post by:
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...
1
by: Frank Milverckowitz | last post by:
Hi, I'm trying to do something common and what should be simple using the GridView "Add Columns" feature in Visual Studio 2005. All I want to do is add a Hyperlink column that will take the...
1
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...
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
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.