473,396 Members | 2,002 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.

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 6308
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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.