Problem with hyperlink column in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kimbred
    New Member
    • Jan 2009
    • 47

    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.

    Code:
    <asp:GridView ID="gvEmployeesBenefits" runat="server" DataSourceID="Benefits" Style="z-index: 100;
        left: 0px; top: 0px" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        GridLines="Horizontal" onrowdatabound="gvEmployeesBenefits_RowDataBound">
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="BGAN8" HeaderText="Emp#" 
                ReadOnly="True" Visible="False" />
            <asp:BoundField DataField="BGPLAN" HeaderText="Plan" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="BGAOPT" HeaderText="Option" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="BAEXA" HeaderText="Plan Description" 
                ReadOnly="True" />
            <asp:BoundField DataField="BGEFT" HeaderText="Enrollment Date" 
                ReadOnly="True" />
            <asp:BoundField DataField="BAFDBA" HeaderText="BAFDBA" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="BASDBA" HeaderText="BASDBA" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField AccessibleHeaderText="RT" DataField="RT" 
                DataFormatString="{0:N2}" HeaderText="RT" />
            <asp:BoundField DataField="YTD" DataFormatString="{0:N2}" HeaderText="YTD" 
                ReadOnly="True" />
            <asp:HyperLinkField HeaderText="Website" DataNavigateUrlFields="Website" 
                DataTextField="Website" />
        </Columns>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>
    Last edited by Frinavale; May 6 '09, 07:58 PM. Reason: Added code tags. Please post code in [code] [/code] tags
  • maliksleo
    New Member
    • Feb 2009
    • 115

    #2
    Originally posted by kimbred
    <asp:HyperLinkF ield HeaderText="Web site" DataNavigateUrl Fields="Website "
    DataTextField=" Website" />
    I think you miss the DataNavigateUrl FormatString part from your hyperlinkField.
    use the following code.
    Code:
    <asp:HyperLinkField HeaderText="Website" DataNavigateUrlFields="Website" 
                DataTextField="Website" DataNavigateUrlFormatString="pagename?variable={0}"/>
    maliksleo

    Comment

    • Meganutter
      New Member
      • Mar 2009
      • 47

      #3
      the Gridview tries to locate the website locally unless there is http:// in front of the url, just www. doesnt really work

      Comment

      • balame2004
        New Member
        • Mar 2008
        • 142

        #4
        www should find it out in world wide web.

        Comment

        • Meganutter
          New Member
          • Mar 2009
          • 47

          #5
          i have had occasions where it didnt figure it out, however, one can never be too safe right?

          Comment

          • kimbred
            New Member
            • Jan 2009
            • 47

            #6
            When I put in DataNavigateUrl FormatString="p agename?variabl e={0}" I get the following.

            "Illegal characters in path. "

            Comment

            • shiznit770
              New Member
              • Apr 2009
              • 10

              #7
              Can you give an example of a url that is being bound?

              Comment

              • kimbred
                New Member
                • Jan 2009
                • 47

                #8
                Nex-Tech is making life better by providing world class technology. The leader in home Internet, streaming TV and fiber broadband solutions.

                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.

                Comment

                • Meganutter
                  New Member
                  • Mar 2009
                  • 47

                  #9
                  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://

                  Comment

                  • kimbred
                    New Member
                    • Jan 2009
                    • 47

                    #10
                    Will do. Thanks for your help/

                    Comment

                    Working...