469,889 Members | 1,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,889 developers. It's quick & easy.

Problem with hyperlink column in gridview

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 6097
115 100+
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}"/>
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
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
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
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
Will do. Thanks for your help/
May 6 '09 #10

Post your reply

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

Similar topics

5 posts views Thread by jib | last post: by
3 posts views Thread by Matthias S. | last post: by
2 posts views Thread by Jason | last post: by
3 posts views Thread by TPhelps | last post: by
3 posts views Thread by William LaMartin | last post: by
1 post views Thread by Frank Milverckowitz | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.